Subject: Re: [xsl] difference between select="*" and select="node()" From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Mon, 8 Apr 2002 12:44:36 +0100 |
Hi Karthik, > it's behaving the same way for me :-( > am using Oreilly's XSLT to learn XSLT. > It says that node() selects the attribute as well in addition to the text > nodes. > But still my attribute values do not get printed. > The book also mentions that attribute needs to be selected > explicitly to apply the default rule for attributes. > If node() does that then why does'nt it print? When you do: <xsl:apply-templates select="node()" /> it's short for: <xsl:apply-templates select="child::node()" /> In other words, it selects all the *child* nodes of the current element. Attributes don't count as children, so you don't select any attributes. To select attributes, you have to use the attribute axis: <xsl:apply-templates select="attribute::node()" /> which is more commonly shortened to '@': <xsl:apply-templates select="@node()" /> Usually you use the node test * rather than the node test node() to select attributes <xsl:apply-templates select="@*" /> Technically, * matches the principal node type for whatever axis you use. The only nodes that you can find along the attribute axis are attributes, so doing @* is the same as doing @node(). If you want to select child nodes and attributes at the same time, use the union operator: <xsl:apply-templates select="@* | node()" /> Cheers, 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: [xsl] difference between select, David Carlisle | Thread | Re: [xsl] difference between select, Oleg Tkachenko |
Re: [xsl] difference between select, David Carlisle | Date | [xsl] displaying a xml via a xsl, Sébastien Tisserant |
Month |