Open Programmierschmied opened 5 years ago
Could you please give an example of XMLs an how you‘d like them to be represented in JS. I‘m a bit puzzled as CDATA is just character data. So this should actually work OTOB, not sure why special support is needed.
Am 14.03.2019 um 13:50 schrieb Justinizer notifications@github.com:
Dear developers,
I have to use mixed CDATA contents. It means that the node can have CDATA or text or both mixed. I am not able to change the XSD Schema for a new simply type. For a fast solution I added a regex detection for the use of cdata in the jsonix.js, but I don't think that this is a good solution. Is there a way to keep CDATA from XML file?
My fast solution: if (this.asCDATA && value.match(/<.+>/g) != null)
Best regards, Justin
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
For example:
<content lang="de"><![CDATA[<p>Something<latex>$m \ge 1 g$</latex> text.</p>]]></content>
if i convert it to js and back it gets to:
<content lang="de"><p>Something <latex>$m \ge 1 g$</latex> text.</p><content>
Edit: If I turn CDATA on for this simpletype then every node gets CDATA. Even these which hadn't CDATA before.
Sorry to did bother you.
I have researched in other XML to objects Parser. To mix CDATA with normal content is a mistake by XSD Design. I will please the writer of xsd file to change this.
Thank you for your fast support!
I'm on FOSSGIS2019 so I can't reply promptly.
Technically this
<content lang="de"><![CDATA[<p>Something<latex>$m \ge 1 g$</latex> text.</p>]]></content>
is exactly the same as this
<content lang="de"><p>Something <latex>$m \ge 1 g$</latex> text.</p><content>
I understand that these are different cosmetics but technically it is not really relevant.
However I can follow that you might be interested in actual cosmetics to make XML more readable. The problem is, however the presentation in the JS side. Somehow you will need to distinguish between normal text and CDATA-text. So improving cosmetics on the XML side might lead to much more complex models on the JS side. Which, in my PoV is a too high price.
But here's an idea. Maybe we could implement some automatic that Jsonix automatically produces CDATA sections if the text contains too much markup/special characters? Like if there are more that N <
s, >
s, '
es and &
s then automatically create a CDATA-section.
What do you think?
I think this is a really good idea. Then we got a feature which other parsers like JAXB don't got. I just found out that this is a general parser problem.
I reopen it. So we can find a solution for. Should I write some code and do a merge request. Or do you want to write code yourself?
I just had an idea. Maybe you like: https://github.com/highsource/jsonix/pull/215
This would allow the user to do a conditional CDATA by regex.
if ((this.asCDATA && this.CDATAcondition == null) || (this.asCDATA && value.match(new RegExp(this.CDATAcondition)) ))
Dear developers,
I have to use mixed CDATA contents. It means that the node can have CDATA or text or both mixed. I am not able to change the XSD Schema for a new simply type. For a fast solution I added a regex detection for the use of cdata in the jsonix.js, but I don't think that this is a good solution. Is there a way to keep CDATA from XML file?
My fast solution:
if (this.asCDATA && value.match(/<.+>/g) != null)
Best regards, Justin