RE: [xsl] XSLT test on the name of a node

Subject: RE: [xsl] XSLT test on the name of a node
From: "Tim Watts" <timw@xxxxxxx>
Date: Mon, 25 Mar 2002 17:28:19 +1100
Hi Joerg,

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

> I think the problem is in the above code.
> You are selecting nodes, whose local name is the same as the value of their ld-tag 
> attribute. What you probably want to have is current()/@ld-tag:

> <xsl:variable name="translation" select="$language/node()[local-name() = current()/@ld-tag]" />

I don't understand what makes it different when using current(), although you were right.  The template now works.

I thought by using the template matches I was comparing with the context nodes @ld-tag and I can't quite understand the difference.

> Furthermore node() is a superset of *. node() = * + text() + comment() +
> processing-instruction().

Thanks for that.  You're giving me quite an education! :)

I have included the template as it now stands below.  Could you explain how the current() works with it?

Thanks for all your help.

Tim Watts


<!-- template called to display method -->
<xsl:template name="get_payment_method_details">
<xsl:variable name="paymentsystems" select="document('../paymentsystems.xml')/root" />
<xsl:variable name="merch_pay_details"><xsl:copy-of select="/document/data/merchant/payment" /></xsl:variable>
  <xsl:apply-templates select="$paymentsystems/methods/method[@id=$pmethod]">
    <xsl:with-param name="merch_pay_details" select="$merch_pay_details" />
  </xsl:apply-templates>
</xsl:template>

<xsl:template match="method">
<xsl:param name="merch_pay_details" />
  <xsl:apply-templates select="input" mode="getinfo">
    <xsl:with-param name="merch_pay_details" select="$merch_pay_details" />
  </xsl:apply-templates>
</xsl:template>

<xsl:template match="input" mode="getinfo">
<xsl:param name="merch_pay_details" />
  <tr>
    <td>
      <xsl:value-of select="$language/*[local-name() = current()/@ld-tag]" />
    </td>
    <td>
      <input type="text" name="{concat('payment/', @name)}" />
    </td>
  </tr>
</xsl:template> 

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


Current Thread