Re: difference between select="*" and select="node()"
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
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format