Project

Profile

Help

Bug #2872

closed

XSLT generates output with undeclared namespace prefix

Added by Michael Kay over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XSLT conformance
Sprint/Milestone:
-
Start date:
2016-08-10
Due date:
% Done:

100%

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

Description

From the saxon-help mailing list (Jorge Williams)

Found a weird regression when moving from Saxon 9.4.0-9 to Saxon 9.7.0-7. We have XSLTs that process XML Schemas. After we moved to the latest version of Saxon we found that in some cases the processor would output a result document with an xs prefix that isn’t actually bound to the XMLSchema namespace.

Was able to reproduce with this simple XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
   xmlns:foo="http://rackspace.com/foo"
   exclude-result-prefixes="xsd foo"
   version="2.0">

   <xsl:variable name="elem" as="element()"><element xmlns="http://www.w3.org/2001/XMLSchema"/></xsl:variable>

   <xsl:template match="/">
       <xsl:result-document href="foo.xml" exclude-result-prefixes="xsd foo">
         <foo:foo xmlns:xsd="http://www.w3.org/201/XMLSchema">
             <xsl:apply-templates select="$elem" mode="foo"/>
         </foo:foo>
       </xsl:result-document>
   </xsl:template>

   <xsl:template match="node()" mode="foo">
       <xsl:copy/>
   </xsl:template>


</xsl:stylesheet>

The result foo.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?><foo:foo xmlns:xsd="http://www.w3.org/201/XMLSchema" xmlns:foo="http://rackspace.com/foo"><xs:element xmlns="http://www.w3.org/2001/XMLSchema"/></foo:foo>

Notice that the xs prefix is added but not defined, this didn’t happen in older versions. I know the example above is contrived, but we actually hit those operations in a complex production XSL.

Please register to edit this issue

Also available in: Atom PDF