[xsl] XSLT test on the name of a node

Subject: [xsl] XSLT test on the name of a node
From: "Tim Watts" <timw@xxxxxxx>
Date: Mon, 25 Mar 2002 15:43:47 +1100
Hi,

I have a xslt template that needs to display an XML node based on its name being extracted from another XML node.

In my example:....

For each match of the 'paymentmethod' field, there are different fields which are required to be input by the customer.

For example, for a direct debit payment method:

  <method name="Direct Debit" country="at">
    <input type="text" name="Bankcode" ld-tag="ld-banknumber" />
    <input type="text" name="Accountnumber" ld-tag="ld-accountnumber" />
    <input type="text" name="Accountname" ld-tag="ld-name" />
  </method>

The ld-tag calls a node in another XML file using document(), depending on the language the user is browsing in. (ie. en.xml for english, de.xml for german, it.xml for italian)

The data it contains looks something like...
<language iso="en">
  <ld-banknumber>Bank Number</ld-banknumber>
  <ld-accountnumber>Account Number</ld-accountnumber>
  <ld-accountname>Account Name</ld-accountname>
  ...
</language>

After matching using the method, for each input field I need to display an input field (whose name is the @name) and the matching language tag (which needs to be the ld-tag from the document(en.xml) which has a name equating to the @ld-tag).

I have used the following Xpath, where $language is a variable holding the document(en.xml)

<xsl:variable name="translation" select="$language/node()[local-name() = @ld-tag]" />
and I also tried 
<xsl:variable name="translation" select="$language/*[local-name() = @ld-tag]" />

When I go to display the name using <xsl:value-of select="$translation" />
it keeps shooting blanks, and I can't see what the probem is.

Have I missed something obvious?

Thanks for your help.

Tim Watts


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread