Select a node by name in file with a parameter from another file

W

wabr7030

I have two xml file
1) xml source:
<Indici>
<F1>xxx</F1>
<F2>yyy</F2>
</Indici>


2) File colsDef.xml:

<Columns>
<Column>
<evento>F1</evento>
</Column>
</columns>

I want to take text of node where node name is defined in file colsDef.xml
I use this xsl:

<xsl:variable name="doc" select="document('colsDef.xml')"/>
<table>
<xsl:for-each select="Indici">
<tr>
<xsl:variable name="nodo" select="."/>
<xsl:for-each select="$doc/Columns/Column">
<td>
<xsl:variable name="evento" select="evento"/>
<!--HERE IS THE PROBLEM -->
<xsl:value-of select="$nodo[name()=$evento]"/>

</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>

Can anyone help me?
Thank you
 
D

David Carlisle

<xsl:for-each select="Indici">

so here the current node has name Indici, and that's the node that gets
saved in nodo:

<xsl:variable name="nodo" select="."/>


so this

<xsl:value-of select="$nodo[name()=$evento]"/>

will be empty unless $evento is "Indici".

It looks like you want to select children of Indici, so:

<xsl:value-of select="$nodo/*[name()=$evento]"/>
^^

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top