Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 16 17:14

    ashawley on master

    Update sbt to 1.3.7 Merge pull request #390 from sc… (compare)

  • Jan 16 17:14
    ashawley closed #390
  • Jan 16 16:53
    scala-steward opened #390
  • Jan 10 16:44

    ashawley on master

    Drop dtd.ElementValidator Merge pull request #388 from as… (compare)

  • Jan 10 16:44
    ashawley closed #388
  • Jan 10 16:44
    ashawley edited #388
  • Jan 10 16:42
    ashawley closed #389
  • Jan 10 16:42
    ashawley commented #389
  • Jan 10 16:28
    SethTisue commented #389
  • Jan 10 16:26
    ashawley commented #389
  • Jan 10 16:26
    ashawley commented #389
  • Jan 09 10:38
    lrytz commented #389
  • Jan 08 23:12
    ashawley opened #389
  • Jan 08 20:33
    ashawley synchronize #388
  • Jan 08 20:30

    ashawley on v2.0.0-M1#0.21.0-RC1

    (compare)

  • Jan 08 20:29

    ashawley on master

    Enable dotty in build.sh Merge pull request #387 from as… (compare)

  • Jan 08 20:29
    ashawley closed #387
  • Jan 08 20:27

    ashawley on master

    Update dotty 0.21.0-RC1 Merge pull request #381 from as… (compare)

  • Jan 08 20:27
    ashawley closed #381
  • Jan 08 20:15
    ashawley commented #387
Aaron S. Hawley
@ashawley
Yikes, good catch! All hail the community build!
Nothing obvious, but I'll look in to it.
Aaron S. Hawley
@ashawley
@ptrlaszlo Here's an example of a traversal
object addScope extends scala.xml.transform.RewriteRule {
  override def transform(n: scala.xml.Node): Seq[scala.xml.Node] = n match {
    case elem: scala.xml.Elem =>
      elem.copy(scope = elem.scope.copy(uri = "urn:CollectionResponse", parent = scala.xml.TopScope),
                child = elem.child.map(addScope))
    case n => n
  }
}

val order = <order><ordernumber/></order>

addScope(order)
Peter László
@ptrlaszlo
thanks Aaron!
Marcel Koopman
@marcelkoopman_gitlab
how can i retrieve the xpath of a xml element? I mean the getRelativeXPath or something like that
Aaron S. Hawley
@ashawley
There may have been a Stackoverflow question about that
Here's an answer in Java for all elements
Marcel Koopman
@marcelkoopman_gitlab
i've seen one where the answer was not implemented
Marcel Koopman
@marcelkoopman_gitlab
thx, but i was looking for scala xml solutions
Aaron S. Hawley
@ashawley
Here's a solution using Scala and the Java DOM
Well, scala-xml doesn't come with anything out of the box with this
Aaron S. Hawley
@ashawley
This was similar
Marcel Koopman
@marcelkoopman_gitlab
thx
ethicalbeginner
@nitishram
hi all ,how to parse xml in scala using sax parser?
Seth Tisue
@SethTisue
@nitishram where you are you stuck?
ethicalbeginner
@nitishram
for single xml with one root tag i could take it but for multiple root tags cound't read all
Seth Tisue
@SethTisue
@nitishram showing the code you have so far might help
Brian Kent
@bdkent
Is there a particular reason scala.xml.Utility.serialize works on a StringBuilder rather than something more abstract? As it seems like the only operation used is StringBuilder#append, is there any reason it couldn't be reworked to use something like java.lang.Appendable so that a java.io.Writer could be provided (and the entire XML wouldn't have to exist as a huge string in memory )?
Aaron S. Hawley
@ashawley
Well, althoughscala.xml.Utility.serialize is a published function, it seems that its intended for internal use rather than external. Internally, scala-xml implements a lot of the library on StringBuilder.
You're right, it's not ideal that the entire serialized XML is held in memory.
Aaron S. Hawley
@ashawley
Are you actually using this method directly, or did you run in to memory issues when using other methods?
Brian Kent
@bdkent
Memory issues, yes. I have locally made a version of the serialize method using Appendable and it all seems to work.
Aaron S. Hawley
@ashawley
Cool. I wonder if that improvement could be leveraged in XML.write, generally?
Brian Kent
@bdkent
I don’t see why not.
I used a few implicit classes to limit the actual files that had to change.
aappddeevv
@aappddeevv
Does the latest scala-xml (1.2.0) work with dotty? I'm having a hard time discerning whether what the XML story is with the current RC release of dotty. I saw this but am unsure how it relates.
Aaron S. Hawley
@ashawley
@aappddeevv What are you trying to do?
I'm not aware of any dotty artifacts for scala-xml that have been published, yet.
aappddeevv
@aappddeevv
Simple XML parsing, not creation nor literals. I saw that the scala-xml uses CanBuildFrom which I think is gone in dotty so it started me wondering about what scala.xml might be pulling in and if there are hidden gotchas I should be worried about. Its working in dotty using the scala-xml 2.13 version but I was worried.
Seth Tisue
@SethTisue
Dotty can use Scala 2 binaries, so I would expect it to just work without needing a special artifact to be published for Dotty
CanBuildFrom is already gone in Scala 2.13, so CanBuildFrom isn't a Scala 2 vs 3 difference
at present Dotty still uses the Scala 2.12 stdlib, where CanBuildFrom is still present. but they expect to switch to the 2.13 stdlib quite soon
aappddeevv
@aappddeevv
I just saw that. I'm thinking that once dotty switches to the 2.13 stdlib that this is where there may be a problem unless scala-xml is republished under 2.13--if I read your comment right.
That could happen in as little as 30 days if they keep publishing RC releases each month.
Seth Tisue
@SethTisue
@aappddeevv scala-xml is already published for 2.13
aappddeevv
@aappddeevv
Ah..that's right...I'm getting a transitive dependency that pushes it back to a 2.12 version though for this dotty project. I guess I'll wait and see what happens to that lib and the xml dependency once the dotty stdlib is updated..
Seth Tisue
@SethTisue
:+1:
Aaron S. Hawley
@ashawley
Indeed, seems you need to use the sbt-dotty plugin and 2.12 artifacts to work with dependencies from dotty
I've made some changes to the old scala modules sample repo to show that it works
Mohamedali10
@Mohamedali10
Hello @all, I'am trying to create a large XML file that contains data retrieved from data base, for that I do not want to hold the whole xml in memory but instead I want to write it directly in the disk, any recommendation on implementing this please?
Seth Tisue
@SethTisue
@Mohamedali10 the scala-xml library probably won't be useful to you here, it's designed for in-memory applications. (there's scala.xml.pull, but it's deprecated, for good reasons.) I'd suggest looking into what Java XML libraries support streaming, and use one of those from Scala
Mohamedali10
@Mohamedali10
@SethTisue thanks
Mohamedali10
@Mohamedali10

Hello, @all I would like to write an xml Elem to a file, but I want to set the line separator between each node of the elem, so when opening the file under windows or ubuntu I have the correct format. for example :

val lineSep = System.getProperty("line.separator") 
val xmlData : Elem = <person>
       <firstName>John</firstName>
       <lastName>Doe</lastName>
  <emails>
  <email type=”primary”>john.doe@noone.com</email>
  <email type=”secondary”>john.doe@noone.com</email>
  </emails>
  <address>
  <street>595 Market Street</street>
  <city>San Francisco</city>
  <zip>94105</zip>
  </address>
  </person>

How to write it into a file and considering the lineSep?

Seth Tisue
@SethTisue
(we're discussing this in scala/scala. @Mohamedali10 when you ask the same question in more than one place on the internet, it's polite to mention that fact, so that someone doesn't waste time helping you in one place, if you already got helped in the other place)
Mohamedali10
@Mohamedali10
@SethTisue ok I'am just lookig for better answers thanks