I have encountered a problem when trying to create a subset of XML Schema files using Saxon9B, version 9.0.0.5.

It has to do with the combination of working with XML Schema files as input files, the document() function and the apply-templates element. I am not trying to do any Schema-aware things; just working with Schema files as input documents.

 

Here are the 3 files that illustrate the error:

 

input.xml:

<?xml version="1.0" encoding="UTF-8"?>

<aaa/>

 

test.xsd:

<?xml version="1.0" encoding="UTF-8"?>

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <xsd:element name="Order">

        <xsd:annotation>

            <xsd:documentation>Description of order</xsd:documentation>

        </xsd:annotation>

    </xsd:element>

</xsd:schema>

 

test.xsl:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"

    xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <xsl:template match="/">

        <xsl:apply-templates select="document('test.xsd')//xsd:element"/>

    </xsl:template>

</xsl:stylesheet>

 

When I run 'java net.sf.saxon.Transform -s:input.xml -xsl:test.xsl -o:output.xsd'

I expect no output at all with this transformation (there is no match for the select in the apply-template).

 

However, Saxon9B outputs the text in the <xsd:documentation> tag 'Description of order'.

This invalidates the result document; plain text in an XML document invalidates the document and it’s hard to remove with scripts etc.

 

Is there a work around (setting/parameter?) for the short term and can this be fixed in future versions?

 

Thank you,

 

Wouter Hartog