[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Can a single XPath statement duplicate the functi
> But I would love to get my hands on > more examples like your <drink type="beer"/> resolutions. I have started writing a 'book', well it's more of a pamphlet, that you never know one day might get finished. > I still do not understand, for instance, the emphasis in the literature in > distinguishing between the "root" and "the document node"; it seems not to > have any impact on writing code. The document node contains the root element. So for example: [ document root] <html> <head> ..</head> <body> ..</body> </html> [ /document root] The <html> element is the "root element". The "document node" contains that root element, and has properties associated with it such as the document uri. The term "root node" is a little ambiguous as it's the document-node() if it exists, or the root element if it doesn't. In general it won't affect your code much, but a common issue is when you create variables and then change the sequence type: <xsl:variable name="types"> <type>A</type> <type>B</type> <type>C</type> </xsl:variable> Here the variable $types contains a document-node() (which is created implicitly) that contains 3 <type> elements (the single root element restriction doesn't apply to temporary trees, or the result tree). It's equivalent to: <xsl:variable name="types"> <xsl:document> <type>A</type> <type>B</type> <type>C</type> </xsl:document> </xsl:variable> Those <type> elements are siblings, because they share a common parent - the document-node(). You can access (say) the first <type> using $types/type[1], because $type returns the document node, and /type[1] returns its first <type> child. If you change the sequence type of the variable to: <xsl:variable name="types" as="element(type)+"> <type>A</type> <type>B</type> <type>C</type> </xsl:variable> The variable $types now contains 3 parentless <type> elements. They are no longer siblings because they don't share a common parent, and you access the first one using $types[1] because $types return the 3 elements. -- Andrew Welch http://andrewjwelch.com
|
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
|