Project

Profile

Help

Bug #2296

closed

Serializer.SetOutputWriter seems to ignore omit-xml-declaration setting [Saxon-HE 9.6.0.4N]

Added by Emanuel Wlaschitz almost 10 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Category:
.NET API
Sprint/Milestone:
Start date:
2015-01-20
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.6
Fix Committed on Branch:
9.6
Fixed in Maintenance Release:
Platforms:

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

Program.cs (2.31 KB) Program.cs Emanuel Wlaschitz, 2015-01-20 11:19

Related issues

Has duplicate Saxon - Bug #2464: xsl:output method 'html' and DOCTYPE decl problem in s9apiDuplicateO'Neil Delpratt2015-10-06

Actions
Actions #1

Updated by O'Neil Delpratt almost 10 years ago

  • Assignee set to O'Neil Delpratt
  • Priority changed from Low to Normal
  • Found in version set to 9.6

Thanks for reporting the issue you have found and sending us a repo. I will investigate it and get back to you shortly.

Actions #2

Updated by O'Neil Delpratt almost 10 years ago

  • Status changed from New to In Progress
Actions #3

Updated by O'Neil Delpratt almost 10 years ago

Hi, I am still investigating the cause of the omit-xml-declaration option being ignored. It seems that the default option in the Serializer is over riding what is set in the stylesheet.

As a workaround you could do the following on the Serializer object in your code:

destination.SetOutputProperty(new QName(omit-xml-declaration), "yes");
Actions #4

Updated by O'Neil Delpratt almost 10 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 0 to 100

Bug fixed and committed to subversion. The problem was the default output properties from the executable of the stylesheeet were not been passed to the Serializer destination.

Change applied in the XsltTransformer class. The patch will be available in the next maintenance release.

I have added a nunit test case to track for regression.

Actions #5

Updated by O'Neil Delpratt almost 10 years ago

  • Status changed from Resolved to Closed
  • Fixed in version set to 9.6.0.5

Bug fix applied in the Saxon 9.6.0.5 maintenance release.

Actions #6

Updated by O'Neil Delpratt about 9 years ago

  • Has duplicate Bug #2464: xsl:output method 'html' and DOCTYPE decl problem in s9api added
Actions #7

Updated by O'Neil Delpratt about 9 years ago

  • Sprint/Milestone set to 9.6.0.5
  • Applies to branch 9.6 added
  • Fix Committed on Branch 9.6 added
  • Fixed in Maintenance Release 9.6.0.5 added

Please register to edit this issue

Also available in: Atom PDF