Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 04 16:39
    ashawley closed #373
  • Dec 04 16:39
    ashawley commented #373
  • Dec 04 16:18
    lrytz commented #373
  • Dec 04 16:04
    ashawley commented #373
  • Dec 04 15:52
    lrytz commented #373
  • Dec 04 15:34
    ashawley commented #376
  • Dec 04 15:32

    ashawley on master

    Update Scala.js to 1.0.0-RC1 Merge pull request #375 from as… (compare)

  • Dec 04 15:32
    ashawley closed #375
  • Dec 04 15:16
    ashawley commented #376
  • Dec 04 15:11
    ashawley commented #373
  • Dec 04 15:10
    ashawley closed #363
  • Dec 04 15:08
    ashawley commented #373
  • Dec 04 09:07
    lrytz commented #373
  • Dec 04 09:02
    lrytz commented #373
  • Dec 04 07:16
    ashawley commented #373
  • Dec 04 07:16
    ashawley commented #373
  • Dec 04 07:13
    ashawley opened #376
  • Dec 04 07:08

    ashawley on v2.0.0-M1#sjs_1.0.0-RC1

    Update Scala.js to 1.0.0-RC1 on… Publish Scala.js from tag in Tr… (compare)

  • Dec 04 06:20
    ashawley commented #373
  • Dec 04 05:29
    ashawley opened #375
Peter László
@ptrlaszlo
it seems that adding the scope doesn't apply to the child elements
Aaron S. Hawley
@ashawley
Yeah, seems you'll need to traverse the tree and add the scope.
Seth Tisue
@SethTisue
@ashawley what do you make of scala/scala-xml#253 ?
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