Reputation: 83
I'd like to know if there is a known error in the way Saxon-JS handles CDATA containing elements.
I have a working XSLT 3.0 and XML process that includes taking text from a CDATA containing element and applying HTML markup in the transformation. I'll try asking the question without posting the script.
I'm using Saxon-HE 9.8.0.3 and trying the lasted Saxon-JS.
Everything converted from the .xsl
files to the .sef
files works except the expected format of the text taken from the CDATA containing element.
I have an element <docText>
that only contains <![CDATA[ ... ]]>
enclosed multiline text.
I call the template with something like:
<xsl:apply-templates select="ancestor::document/docText"/>
I match with <xsl:template match="docText/text()">
The final manipulation of the text in <docText>
contained in a variable is output with the following:
<xsl:value-of select="$step9-2" disable-output-escaping="yes" />
Again, the output is correct with working HTML markup when I use the original transformation with Saxon-HE, XML and XSLT 3.0 from command line in Java. The transform script is almost identical for use with Saxon-JS and all the logic works except the formatting of the text originally in the CDATA sections. The text is output but as unformatted.
Is there any reason the error might be due to the way Saxon-JS does or doesn't handle CDATA sections the way Saxon-HE does?
Michael
Upvotes: 0
Views: 382
Reputation: 163322
Yes there is a known issue: https://saxonica.plan.io/issues/3385
Without seeing more of your code, I'm not sure whether that issue is relevant. The bug says that CDATA sections are converted to text nodes if there is any whitespace stripping in effect, but not otherwise, so a useful experiment would be to see what happens if you add to your stylesheet
<xsl:strip-space elements="a-dummy-element-name"/>
This will trigger whitespace stripping which also has the effect of turning CDATA nodes into ordinary text nodes.
However, this isn't going to solve the problem that your code is reliant on disable-output-escaping. If your CDATA/text node contains HTML markup that needs to be copied into the HTML page, the only way to do this under Saxon-JS is to parse the HTML into a tree of nodes, and add the nodes to the HTML DOM. If the HTML is well-formed XML you can do this using the parse-xml() function; if not, you may have to call out to Javascript.
Upvotes: 1
Reputation: 167506
See http://www.saxonica.com/saxon-js/documentation/index.html#!conformance/xslt30 saying
Saxon-JS does not implement the following optional features of the specification: schema-awareness, serialization, streaming, higher-order functions, and disable-output-escaping
Upvotes: 1