Bug #2296
closedSerializer.SetOutputWriter seems to ignore omit-xml-declaration setting [Saxon-HE 9.6.0.4N]
100%
Description
After #2251 was resolved and 9.6.0.4N was released, we ran our tests again; and it seems we didn't see two particular ones amidst the other failures leading to #2251.
In one particular case, we use an XmlReader
as input and a StringWriter
as output to the transformation. The intent is to gather a bunch of XML fragments (that may not be well-formed, due to being empty, plain-text or having multiple root elements) from complete (and well-formed) documents, glue them together in our code, and act further on that.
With 9.6.0.4N, the XML fragment created contains an XML-Declaration, even when the XSLT specifies @omit-xml-declaration="yes"@. This didn't happen with 9.5, and is a problem since we assume that after glueing them together (and wrapping it in a root element), we can parse the whole thing as XML (best case we get a list of XML elements within our artificial root; worst case we get our root element with one huge plain-text node).
This fails on our side since the root element contains a bunch of XML-Declarations.
Please see the attached sample code for a reproduction case.
In the sample, I simply pass a static '@@' and want to produce a static '@@' for further use.
However, what the transformation actually returns is '@<?xml version="1.0" encoding="UTF-8"?>@' (that backslash is placed intentionally and not part of the output, but otherwise the @ formatting seemed to eat the declaration).
The used XSL fragment is in the sample (as a comment), but I'll replicate it here aswell (i tried to keep it as straight-forward as possible for the sake of showing the problem; changing the XSLT Version or using different xsl:output options does not seem to change anything):
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="/"><output1/><output2/></xsl:template>
</xsl:stylesheet>
In the code itself, it makes no difference using a TextWriter@, @FileStream
or @MemoryStream@.
Files
Related issues
Please register to edit this issue