How to create a list of nodes?

Here should go questions about transforming XML with XSLT and FOP.
kdavyd
Posts: 2
Joined: Fri Jul 13, 2007 11:48 pm
Location: Cambridge, MA

How to create a list of nodes?

Post 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
jkmyoung
Posts: 89
Joined: Mon Mar 06, 2006 10:13 pm

Post by jkmyoung »

Can you use XSLT 2.0? If so you can use the matches() function
eg.
matches(., "X[1-9]+Y[1-9]+")
jkmyoung
Posts: 89
Joined: Mon Mar 06, 2006 10:13 pm

Post by jkmyoung »

Assuming all match:
<xsl:for-each select="$data_doc//Array/@Code">
<xsl:value-of select="."/><xsl:text> </xsl:text>
</xsl:for-each>
kdavyd
Posts: 2
Joined: Fri Jul 13, 2007 11:48 pm
Location: Cambridge, MA

Post by kdavyd »

Thanks, jkmyoung

The second option worked
Post Reply