Re: node() as pattern
Hi Dave, > Anyone got a nice clear description of what's happening > with such as > > match='/node()/node()/node()/node()/node()' > > please? This matches the 7th child node of the 8th child node of the 2nd child node of the 8th child node of the 2nd child node of the root node. So it'll only match anything if the root node has at least two children, the second of which has at least 8 children, the 8th of which has at least 2 children, the 2nd of which has at least 8 children, the 8th of which has at least 7 children. Assuming that you're dealing with a well-formed XML document, containing only elements (no processing instructions, comments or text), it won't match anything since the root node doesn't have a second child. Your other example was: <doc> <nd1> <nd2>..</nd2> <nd3/> </nd1> </doc> (well, I assume that's what you meant -- you had an extra closing tag for the nd1 element that didn't fit) with: <xsl:template match='/node()/node()'> ... </xsl:template> This matches the second child node of the first child node of the root node. The first child node of the root node is the doc element, but that only has one child node (the nd1 element), so again, the template doesn't match any nodes. Perhaps it would help you to imagine the nodes numbered by their position within their parent as follows: <doc node="1"> <nd1 node="1"> <nd2 node="1">..</nd2> <nd3 node="2" /> </nd1> </doc> So templates that would match these nodes would be: /node() (matches doc) /node()/node() (matches nd1) /node()/node()/node() (matches nd2) /node()/node()/node() (matches nd3) Given that you don't have any processing instructions, comments or text nodes, using node() is exactly the same as using *. 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