Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsl:variable, is it useful anymore?! Expert required! 1

Status
Not open for further replies.

Clemintine

Programmer
Oct 9, 2001
7
GB
Hi there,
I have a largish products file containing nested EXPANSION's and I've been using a xml:variable in a template match of the following form to return the contents of a selected expansion.:

<xsl:variable name=&quot;EID&quot; select=&quot;string(//ITEMS/@SELECTEDID)&quot;/>
<xsl:template match=&quot;EXPANSION[@SELECTEDID=$EID]&quot;>
</xsl:template>

Originally, I started off using a template match of
EXPANSION[@EXPANSIONID=//ITEMS/@EID]
but discovered that it was incredibly slow taking 5-10 seconds to render and then I read that using a xsl:variable like this is a good way, and sure enough, as soon as I switched to testing each template against a variable containing the value converted to its string value my whole page rendered without pause.
Recently upgrading to Miscrosoft's non-beta full blown v3.0 parser I was shocked that my pages started returning :

msxml3.dll error '80004005'

Variables may not be used within this expression. EXPANSION[@EXPANSIONID=-->$EID<--]

Hoping it was just something that a patch fixed later I updated to SP2, to find the problem still there and that using a match against //ITEMS/@EID instead, is still just as slow taking 8-10 seconds to render a 80-100k file.

So anyone got any ideas of what the modern day 'working' solution is?

Kind Regards Clemintine.
 
i've never used a variable inside a template match before so i'm not sure if it's limited in any way.
using &quot;//ITEMS&quot; tho is very inefficient. &quot;//&quot; is bad, it is best to be as explicit as you can when writing xpath.
the only thing you could try is putting
<xsl:template match=&quot;EXPANSION&quot;>
<xsl:choose>
<xsl:when test=&quot;@SELECTEDID=$EID&quot;>
...
</xsl:when>
<xsl:eek:therwise>
..
</xsl:eek:therwise>
</xsl:choose>
</xsl:template>

this may not be too helpful tho. if you are still stuck then post some of your xml structure.
 
Thanks for that, I sort of thought of that solution but thought that since matching all expansions and then going in to test further, would be more overhead. As I said strangely the old versions of the parser worked gr8 hehe thx again :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top