[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: thoroughly confused about node() matching

Subject: RE: thoroughly confused about node() matching
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Tue, 4 Mar 2003 00:00:20 -0000
xsl template match node
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:  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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.