[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSLT test on the name of a node

Subject: Re: XSLT test on the name of a node
From: "Joerg Heinicke" <joerg.heinicke@xxxxxx>
Date: Mon, 25 Mar 2002 09:07:27 +0100
xslt test tag name
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@xxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Monday, March 25, 2002 7:28 AM
Subject: RE:  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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.