[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: A problem using the xsl:key facility
On 20/07/2010 21:17, Nathan Potter wrote:
The key() function, when called with two arguments, always searches within the current document (more accurately, the document containing the context node). Your xsl:for-each changes the current document, so you are searching the wrong thing. In XSLT 2.0 you can use the third argument of the key() function to indicate which document you want to search. I've included some other comments on your code in case you find them helpful. Calling boolean() is redundant here: the test attribute does it anyway. That's a rather longwinded way of doing<xsl:element name="NestedDataset"> <xsl:attribute name="name"> <xsl:value-of select="@name"/> </xsl:attribute> <xsl:apply-templates/> </xsl:element> <NestedDataSet name="{@name}"><xsl:apply-templates/></NestedDataSet>
You can almost invariably rewrite this as <xsl:variable name="sName" select="."/> (or perhaps select="string(.)"). This isn't just a stylistic issue, it's a lot more efficient to bind a variable to a node or a string than to construct a temporary tree. Michael Kay Saxonica
|
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
|