Subject: RE: [xsl] thoroughly confused about node() matching From: "Michael Kay" <mhk@xxxxxxxxx> Date: Tue, 4 Mar 2003 00:00:20 -0000 |
As a pattern, match="node()" is short for match="child::node()", which matches any node that is a child of anything - which means elements, text nodes, comments, and PIs, but not root nodes, attributes or namespaces. What's probably confusing you is that as a node-test, node() matches any node. So if it's used with a different axis, e.g. match="attribute::node()" or match="ancestor::node()", it will match other node types than these. Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of > Robert P. J. Day > Sent: 03 March 2003 16:08 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > 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 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: thoroughly confused about, Dimitre Novatchev | Thread | RE: [xsl] thoroughly confused about, David N Bertoni/Camb |
RE: [xsl] Maintainability Problem, Michael Kay | Date | [xsl] putting number values, Dionisio Ruiz de Zar |
Month |