Thank you Michael. That fixed the issue (adding a <xsl:template match="text()"/> element)


Sorry for cluttering the mailing list with non saxon specific questions. I did not realize this was a standard XSLT rule.

Next time I will first test with other XSLT processors before concluding it’s a Saxon thing.

Wouter Hartog


From: Michael Kay []
Sent: Thursday, May 22, 2008 1:16 PM
To: 'Mailing list for the SAXON XSLT and XQuery processor'
Subject: Re: [saxon] XML Schema files,document() and apply-templates creates superfluous output


When there is no user-written template rule for a node selected by apply-templates, the built-in template rule is invoked: see


For an element, this effectively does xsl:apply-templates, causing the children to be processed; for a text node it does <xsl:value-of select="."/>. This explains the output you are seeing.


If you don't like the built-in behaviour, just override it. For example you can add a rule <xsl:template match="*"/>.


The Saxon list is intended for questions that are specific to the Saxon product. If you want general XSLT coding help, I would advise going to


Michael Kay


From: [] On Behalf Of Wouter Hartog
Sent: 22 May 2008 18:04
Subject: [saxon] XML Schema files,document() and apply-templates creates superfluous output

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

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:



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




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

<xsd:schema xmlns:xsd="">

    <xsd:element name="Order">


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






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

<xsl:stylesheet xmlns:xsl="" version="2.0"


    <xsl:template match="/">

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




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