[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Attributes?
> In XSLT 1.0, match="g" matches exactly the same elements as > match="//g". > There's a slight difference in 2.0, because match="//g" > will only match g elements that are in a tree with a > document node as its root - which means the processor has > extra checks to do in this case. > > Confused. Don't *all* elements exist in a tree with a document > node as its root? > > Under what circumstances might an element *not* have such a > root please? > No, XSLT 2.0 (and XQuery) allow you to create free-standing nodes. For example, there was a question a few days ago (I think on the Saxon list rather than here) from someone who wanted to write a function that returned a set of attribute nodes: <xsl:function name="my:atts" as="attribute()"> <xsl:param name="p"/> <xsl:attribute name="a" select="{$p+1}"/> <xsl:attribute name="b" select="{$p+2}"/> </xsl:function> (Essentially the same as an attribute-set, except that attribute sets do not allow parameters.) You can copy these attributes to an element, like this: <e> <xsl:copy-of select="my:atts(17)"/> </e> But you can also apply-templates to them: <xsl:apply-templates select="my:atts(29)"/> If you try to find the parent of one of these attributes, you find it hasn't got one: <xsl:value-of select="count(my:atts(6)/..)"/> displays "0". And of course the same applies to elements. Michael Kay
|
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
|