Subject: Re: Antwort: comments. (Re: key() Re: Saxon VS XT) From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Mon, 14 Aug 2000 10:15:42 +0100 |
Gary, >node() is an abbreviation for child::node(). This will never match / >since it is not the child of anything. This is explained in XSLT §5.2 >in the node() example. Also note that this can never match an attribute >or namespace node since they are also not considered children of their >parents!! See XPath §§ 5.3 and 5.4. Thanks for pointing that out. XSLT (Section 5.2) explicitly says: * node() matches any node other than an attribute node and the root node (and doesn't say anything explicit about namespace nodes). For the benefit of those who are as confused as me over this: I had been looking at XPath which says: "A node test node() is true for any node of any type whatsoever." and in my head translating match="X" to match="self::X" (i.e. self::node()). Wrong, wrong, wrong: match patterns are all about what would happen if you evaluated them *in a particular context* and answering the question "would this node be in the resulting node set?". So you have to imagine a situation in which the current node is either the node you're wanting to match, or one of its ancestors, and what would happen if you did: <xsl:value-of select="---expression---" /> So in this case: <xsl:value-of select="node()" /> Because the default for a select expression is the child axis, this is the same as saying: <xsl:value-of select="child::node()" /> So, the nodes that we're matching are any nodes that have a parent that have this node as a child node. The root node doesn't have a parent, and attribute and namespace nodes are not children of their parents. Therefore, to match these as well, the correct pattern for a named-template replacement is: <xsl:template match="node() | / | @*" mode="XXX"> ... </xsl:template> As far as I understand it, namespace nodes can't be matched against as the 'namespace' axis isn't allowed within patterns. Puzzling over the why of this has transformed my understanding of patterns. Thanks, Jeni Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Antwort: comments. (Re: key() R, Gary L Peskin | Thread | Re: Complete XSLT Reference and int, Oliver Becker |
Re: Failed saxon:output, Oliver Becker | Date | Embedding HTML Doc into XSL or XML, Sunitha |
Month |