This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: XSLT test on the name of a node


A [...] is a predicate. Everything in a predicate refers to the node which
belongs to the predicate:

node[name() = @attr]   (a node, whose name is the same as the value of the
attr; so it's true for <node attr="node"/>)

In your case it was the same. You selected all nodes, whose local name is
the same as the value of their ld-tag attribute: <node ld-tag="node"/> for
example. With current() you change back to the context-node (on which the
template matches). Otherwise local-name() would give you back the local-name
of the matched node too, and not of the node you want to select.

$language/node()[local-name() = current()/@ld-tag]

Hope this helps,

Joerg


----- Original Message -----
From: "Tim Watts" <timw@3d3.com>
To: <xsl-list@lists.mulberrytech.com>
Sent: Monday, March 25, 2002 7:28 AM
Subject: RE: [xsl] XSLT test on the name of a node


> 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
>


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]