[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Put Xpath in variable
(please, don't use "reply to all", that way, I get the message twice,
once from my normal inbox, and once from the xsl list. Just reply to the
xsl list, that is enough)
Hi Matteo, It would help if you would simply put the XML in the mail. You use round brackets (parentheses), but you better use angle brackets. Re-writing your post, it looks like this: <xsl:for-each select="field[contains(@id, 'containerWidth')]"> <xsl:variable name="var1" select="@value" /> </xsl:for-each> I think you have just a little scope-confusion here. The variable only exists in the context of the for-each and it will contain the value for @value of each iteration (instance) of the matching select in your 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" /> And place it somewhere outside the scope of your for-each (well, you may put it inside, but that is a waste of system resources because it needs to be calculated again each time and you will have to adjust the xpath a bit). "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. HtH, Cheers, Abel Braaksma http://abelleba.metacarpus.com m.core@xxxxxxxxxxxxxxxx wrote: Thx a lot Abel... I have one last question if i make something like this:
|
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
|