Page 1 of 1

How to create a list of nodes?

Posted: Sat Jul 14, 2007 12:00 am
by kdavyd
Hi all,

I have an XSL that selects arrays with a given @Code from my data XML (data_doc) like this:

Code: Select all


<xsl:if test="count($data_doc//Array[(contains(@Code, 'X1Y1') or contains(@Code, 'X2Y2'))])!= 0">
<xsl:do_something />
</xsl:if>
Do you know if there is a way to output the list of array @Code names to a string (i.e. "X1Y1 X2Y2 X3Y3 etc...") - there can be arbitrarily many of them?

This is needed so I can call a JS function with that string as a parameter and form the test="..." query based on user input.
I've tried looking on the net, but haven't found any info on that topic

Thanks!
kdavyd

Posted: Mon Jul 16, 2007 6:41 pm
by jkmyoung
Can you use XSLT 2.0? If so you can use the matches() function
eg.
matches(., "X[1-9]+Y[1-9]+")

Posted: Mon Jul 16, 2007 6:42 pm
by jkmyoung
Assuming all match:
<xsl:for-each select="$data_doc//Array/@Code">
<xsl:value-of select="."/><xsl:text> </xsl:text>
</xsl:for-each>

Posted: Mon Jul 16, 2007 9:32 pm
by kdavyd
Thanks, jkmyoung

The second option worked