Subject: Re: [xsl] A problem using the xsl:key facility From: Nathan Potter <ndp@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 23 Jul 2010 13:22:59 -0400 |
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.
<xsl:choose> <xsl:when test="boolean(dataset)">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>
<xsl:variable name="sName"><xsl:value-of select="."/></xsl:variable>
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
============================================================ Nathan Potter Oregon State University, COAS ndp at coas.oregonstate.edu 104 Ocean. Admin. Bldg. 541 231 3317 voice Corvallis, OR 97331-5503 541 737 2064 fax
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] A problem using the xsl:k, Lars Huttar | Thread | [xsl] How to disable/turn off the i, Jack Bush |
Re: [xsl] How to disable/turn off t, David Carlisle | Date | Re: [xsl] How to disable/turn off t, Jack Bush |
Month |