Robert,
According to the XSLT 1.0 spec
(http://www.w3.org/TR/1999/REC-xslt-19991116),
section 5.2 (http://www.w3.org/TR/1999/REC-xslt-19991116#patterns), node()
matches "any node other than an attribute node and the root node".
Dan.
-----Original Message-----
From: Robert P. J. Day [mailto:rpjday(_at_)mindspring(_dot_)com]
Sent: 03 March 2003 16:08
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] thoroughly confused about node() matching
having thoroughly exhausted everyone on the docbook-apps
list with this, i'd like to get some clarification on what
does and does not constitute a template match with "node()".
given a couple test files:
1.xml:
----------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<book id="id1">
<?whatever?>
<!-- and a worthless comment -->
<chapter id="chap2"><title>chapter 1</title>
<para>this is a paragraph in chapter 1.</para>
</chapter>
</book>
----------------------------------------
1.xsl
----------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="@*">
<xsl:copy/>
</xsl:template>
<xsl:template match="node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
---------------------------------------
i get two different outputs using xsltproc and saxon.
xsltproc does *not* generate output for comments or
processing instructions, while saxon *does*.
i have read a number of docs, including tidwell's "XSLT",
kay's "XSLT Programmer's Reference", and the online docs
at www.w3.org, and i can say with assurance that every one
of those sources disagrees with the others when it comes to
defining what does and does not match "node()" in the context
of a template match. (e.g., kay, p. 440 states that node()
will *not* match attribute nodes, while tidwell, p. 51, says
it will. argh.)
rather than get into the gory details of what each of these
sources says, it seems obvious to this here newbie that
*at least* one of xsltproc or saxon is generating incorrect
output.
can anyone point me at the definitive explanation as to
what nodes the "node()" match really matches? specifically,
should the rules in my stylesheet match comment()s or
processing-instruction()s, to override the built-in
behavior which is to ignore them?
rday
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
***************************************************************************
This communication (including any attachments) contains confidential
information. If you are not the intended recipient and you have received this
communication in error, you should destroy it without copying, disclosing or
otherwise using its contents. Please notify the sender immediately of the
error.
Internet communications are not necessarily secure and may be intercepted or
changed after they are sent. Abbey National Treasury Services plc does not
accept liability for any loss you may suffer as a result of interception or any
liability for such changes. If you wish to confirm the origin or content of
this communication, please contact the sender by using an alternative means of
communication.
This communication does not create or modify any contract and, unless otherwise
stated, is not intended to be contractually binding.
Abbey National Treasury Services plc. Registered Office: Abbey National House,
2 Triton Square, Regents Place, London NW1 3AN. Registered in England under
Company Registration Number: 2338548. Regulated by the Financial Services
Authority (FSA).
***************************************************************************
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list