[Cuis-dev] YAXO and entity
Phil B
pbpublist at gmail.com
Mon Sep 27 09:10:44 PDT 2021
Juan,
Two things:
1) When reading XML files you have to be able to consume CR and/or LF as
the majority of XML files are going to come from non-Smalltalk sources
using who-knows-what conventions. This goes for the structure as well as
the content. So we can't say 'just use LF'. It is fine (even preferred)
to emit only LF (for a generic end of line, not an encoded entity) when
writing XML files. See https://www.w3.org/TR/REC-xml/#sec-line-ends
2) When you want to ensure your CR's and/or LF's are preserved 'as is' in
attributes/nodes, they need to be encoded as Hilaire is doing. They need
to be unencoded along with other entities when parsed.
If you don't encode your CR's inside attributes/nodes, I believe many/most
XML generators will translate them to LF's (or even omit them) when the XML
file is written per item 1. Now whether or not Hilaire's code should want
the CR's encoded is a valid point to consider as that's a content question
rather than an XML one. But it is valid from an XML standpoint to do what
he is doing.
Thanks,
Phil
On Mon, Sep 27, 2021 at 6:53 AM Juan Vuletich via Cuis-dev <
cuis-dev at lists.cuis.st> wrote:
> On 9/26/2021 10:27 AM, Hilaire Fernandes via Cuis-dev wrote:
>
> Hi Nicolas,
>
> I can read most of DrGeo xml files, only xml entity like
(carriage
> return I guess) and (tabulation) are not translated and kept as is
> when I read the file.
>
> Hilaire
> Le 26/09/2021 à 10:57, Nicola Mingotti a écrit :
>
> i was parsing successfully a libreoffice file with YAXO.
>
> --
> GNU Dr. Geohttp://drgeo.euhttp://blog.drgeo.eu
>
>
> It looks like the attached works. Test adding #withCuisLineEndings, so
> that CR characters from Pharo are converted to LF:
>
> | doc |
> doc _ XMLDOMParser parseDocumentFrom: 'Curve and slope.fgeo' asFileEntry
> readStream.
> ((doc elementAt: #drgenius) firstTagNamed: #code) contentString
> withCuisLineEndings.
>
> I don't know the XML spec in full detail, but it looks like the
> conversions in the attach are needed. Anyone knows better?
>
> Thanks,
>
> --
> Juan Vuletichwww.cuis-smalltalk.orghttps://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Devhttps://github.com/jvuletichhttps://www.linkedin.com/in/juan-vuletich-75611b3
> @JuanVuletich
>
> --
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st
> https://lists.cuis.st/mailman/listinfo/cuis-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20210927/b0bd97b6/attachment.htm>
More information about the Cuis-dev
mailing list