When there is no user-written template rule for a node selected by apply-templates, the built-in template rule is invoked: see
 
http://www.w3.org/TR/xslt20/#built-in-rule
 
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 xsl-list@mulberrytech.com.
 
Michael Kay
http://www.saxonica.com/


From: saxon-help-bounces@lists.sourceforge.net [mailto:saxon-help-bounces@lists.sourceforge.net] On Behalf Of Wouter Hartog
Sent: 22 May 2008 18:04
To: saxon-help@lists.sourceforge.net
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 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