by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jul 02 01:48
    scala-steward opened #437
  • Jun 28 00:51
    scala-steward opened #436
  • Jun 25 19:52
    SethTisue commented #430
  • Jun 25 19:52

    SethTisue on master

    Update sbt-dotty to 0.4.1 (#424… (compare)

  • Jun 25 19:52
    SethTisue closed #424
  • Jun 25 19:51

    SethTisue on master

    Latest stable release is 1.3.0 Add more related projects Merge pull request #435 from as… (compare)

  • Jun 25 19:51
    SethTisue closed #435
  • Jun 01 19:55
    ashawley edited #432
  • Jun 01 19:01
    ashawley synchronize #435
  • Jun 01 18:55
    ashawley opened #435
  • Jun 01 18:53

    ashawley on master

    Update sbt to 1.3.12 Merge pull request #434 from sc… (compare)

  • Jun 01 18:53
    ashawley closed #434
  • May 31 18:24
    SethTisue closed #433
  • May 31 18:24
    SethTisue commented #433
  • May 31 02:54
    scala-steward opened #434
  • May 29 18:54
    scala-steward opened #433
  • May 27 23:36
    SethTisue commented #429
  • May 27 16:35
    SethTisue commented #432
  • May 27 15:01
    ashawley edited #346
  • May 27 15:00
    ashawley closed #409
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
Francois Armand
@fanf

I see the following change in behavior between scala 2.12 and 2.13:
scala 2.12:

scala> import scala.xml._
import scala.xml._

scala> val a: NodeSeq = <a>Hello</a>
a: scala.xml.NodeSeq = <a>Hello</a>

scala> a ++ <b>hi</b>
res0: scala.xml.NodeSeq = NodeSeq(<a>Hello</a>, <b>hi</b>)

Scala 2.13:

scala> a ++ <b>hi</b>
res0: Seq[scala.xml.Node] = List(<a>Hello</a>, <b>hi</b>)

That change has a very deep reach for us, because Lift doesn't interpret both type in the same way: it applies template transformation one time for a NodeSeq (it's only one template), and N times for List[Node] (it's a list of template). Our web application is totally broken, and it's almost impossible to find all places which would need a type ascription (and it would bloat a lot the resulting code.

Is there a way to get back the old behavior? Perhaps we are missing a new implicit? Perhaps the implicit precedence in NodeSeq changed and it could be adpated?
Any insight would be appreciated.

(reposting here from scala/scala, seems more appropriate, I wasn't aware of the existence of that chan)
Seth Tisue
@SethTisue
(in the other room, I suggested opening a ticket in the scala-xml repo)
Francois Armand
@fanf
thanks @SethTisue , will do so, I wanted to have a feedback from here before opening ticket
Francois Armand
@fanf
for record: scala/scala-xml#392
David Geirola
@geirolz

Hi guys, i have a question for you. I'm trying to map Elem children but the result is not what i expected.

val elem: Elem =
      <a>
        <b>1</b>
        <b>2</b>
        <b>3</b>
      </a>

    val result = elem.child.map(k => <c>{k.text}</c>)

Returns

ArrayBuffer(
               <c></c>,
                <c>1</c>,
                <c></c>,
                <c>2</c>,
                <c></c>,
                <c>3</c>,
                <c></c>
    )

Can someone explain me why this happend ? why empty nodes ?

Aaron S. Hawley
@ashawley
The whitespace between the elements is part of the structure.
elem.child.map { 
  case e: Elem => <c>k.text</c>
  case n => n
}
res0: Seq[scala.xml.Node] = List( , <c>k.text</c>,  , <c>k.text</c>,  , <c>k.text</c>,  )
David Geirola
@geirolz
Ok, now it's clear, thank you
Fabian Schüssler
@FabianSchuessler
Hi, how can I change the attribute of a node?
elem \@ "src" = "shouldBeNewValue"
Chris Coppins
@st900_gitlab
Hi everyone, I this might be related to @fanf's point, but how do I prepend an optional element with the result being itself XML i.e. {if (mycondition) { <td> hello </td>} else xml.NodeSeq.Empty} ?? <td> bob </td>
Aaron S. Hawley
@ashawley
@st900_gitlab
scala> <table>{ <td>world</td>.prepended(if (true) { <td>hello</td> } else { NodeSeq.Empty }) }</table>
res0: scala.xml.Elem = <table><td>hello</td><td>world</td></table>
Chris Coppins
@st900_gitlab
@ashawley thanks
Mohamedali10
@Mohamedali10
Hi, suppose that I have the following xml Elem, and I want to convert it into a String in a specific encoding. Is it possible to do that ?
<person id ="1"> 
<name> person1</name>
<age>20</age>
<address> address</address>
</person>
ritschwumm
@ritschwumm
@Mohamedali10 since a string by itself always is (kindof) UTF-16, i guess what you need is a sequence of bytes? in which encoding?
Matt Hughes
@matthughes
Can someone confirm what the latest stable release compatible with 2.13 is? Github project page and releases page are confusing me a bit.
Releases seems to think 1.3.0 is latest and greatest, released on March 16 with 2.0.0M1 being released on Feb 5th.
Aaron S. Hawley
@ashawley
@matthughes Yes, 1.3.0 is the latest stable release. 2.0.0-M1 is unstable.
Matt Hughes
@matthughes
Thanks
Mohamedali10
@Mohamedali10
Hi, is it possible to determine the encoding of an Elem that I read from a file?
Aaron S. Hawley
@ashawley
@Mohamedali10 No, I don't believe the file encoding is an attribute of an Elem. There are a few file-related functions in scala-xml, so there is an encoding setting , but that won't help. The XML declaration could have an encoding attribute, or not, but I don't think that's tracked either. Parts of the code look like there was an effort to try and capture the encoding, but it was abandoned and never completed.
Mohamedali10
@Mohamedali10
thanks @ashawley