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

Discussion in 'XML' started by wabr7030, Mar 8, 2005.

  1. wabr7030

    wabr7030 Guest

    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
     
    wabr7030, Mar 8, 2005
    #1
    1. Advertising

  2. <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
     
    David Carlisle, Mar 8, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,468
  2. CB
    Replies:
    1
    Views:
    592
    Johannes Koch
    Oct 2, 2003
  3. Eddy C
    Replies:
    6
    Views:
    6,431
    Eddy C
    Oct 18, 2005
  4. Tjerk Wolterink
    Replies:
    2
    Views:
    1,437
    Dimitre Novatchev
    Aug 24, 2006
  5. palmiere
    Replies:
    1
    Views:
    413
    Erwin Moller
    Feb 9, 2004
Loading...

Share This Page