Subject: Re: [xsl] Put Xpath in variable From: Abel Online <abel.online@xxxxxxxxx> Date: Mon, 28 Aug 2006 17:21:31 +0200 |
<xsl:for-each select="field[contains(@id, 'containerWidth')]"> <xsl:variable name="var1" select="@value" /> </xsl:for-each>
To resolve this, to get only the first, you can do this: <xsl:variable name="var1" select="field[contains(@id, 'containerWidth')][1]/@value" />
"If i want to make one variable for each values"Not sure what you mean here. You cannot make one variable for each value, because you cannot know beforehand how many values there are. This looks like you want something that is called an array in normal programming languages. Such thing does not exist in XSLT because you cannot change the name of the variable. This is a FAQ. There are several ways around this, but most of the times, a different approach to your problem will help the best.
Cheers, Abel Braaksma http://abelleba.metacarpus.com
Thx a lot Abel... I have one last question if i make something like this:
(xsl:for-each select="field[contains(@id, 'containerWidth')]")
(xsl:variable name="var1" select="@value" /) (/xsl:for-each)
in var1 i put different values one for each instance of containerWidth in the xml tree, infact if i make:
(xsl:value-of select="$var1" /)
it print out this: 45 14 2 6
If i want to make one variable for each values or make a variable that contains only the first value how can i do?
in any case thx all guys this list is very usefull to me
bye Matteo
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Put Xpath in variable, m.core | Thread | [xsl] XSL import, Bernie |
Re: [xsl] Put Xpath in variable, m.core | Date | Re: [xsl] "castable as" explanation, Florent Georges |
Month |