Am Mittwoch, 16. Oktober 2002 17:22 schrieb Jeni Tennison:
Hi Janning,
In my XML Book "In a nutshell" it says:
"node() matches all nodes regardless of type: attribute,
namespace..."
It's true that the *node test* node() matches all nodes regardless
of type. However, a node test never exists alone -- it's always
used alongside an *axis*, for example:
oh yeah, i am a stupid guy. AXIS is the magic word!... Many thanks
for your detailed explanation below. I forgot my self-made rule when
dealing with XPATH:
"Dont use XPATH shorthands when it comes to problems" which leads
normally to question "What is your axis..." :-)
(my second best rule for XPATH is: try thinking in sets of nodes )
BTW: it is acommon fault in many documentations for beginners to
start with abbreviations of XPATH Expressions. I dont like them. In
XSLT you have to type a lot of things anyway. (ok i dont want to miss
them, but they just help you typing faster, not understanding faster,
but i guess thats common for all abbreviations :-)
thanks a lot.
kind regards,
janning
child::node()
attribute::node()
The pattern "node()" is a shorthand for:
child::node()
which matches all nodes *that are children of some other node*.
Attributes are not children of any node, therefore this pattern
doesn't match attributes. If you want to match attributes, you have
to use the attribute axis, e.g.:
attribute::node()
or:
attribute::*
or their shorthands:
@node()
@*
So the identity template is usually written:
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
i.e. match all nodes-that-are-children and all attributes, copy
them, and go on to process their attributes or children, if they
have any.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
-----------------------
PLANWERK 6
websolutions
Herzogstraße 85
40215 Düsseldorf
fon 0211 - 601 606 93
fax 0211 - 601 591 7
vygen(_at_)planwerk6(_dot_)de
http://www.planwerk6.de
-----------------------
-------------------------------------------------------
--
Planwerk 6 /websolutions
Herzogstraße 86
40215 Düsseldorf
fon 0211-6015919
fax 0211-6015917
http://www.planwerk6.de
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list