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

Re: newbie xsl:if

Subject: Re: newbie xsl:if
From: "Alistair MacDonald" <AlistairMacDonald@xxxxxxxxxxxxx>
Date: Wed, 09 Jun 1999 11:24:08 +0100
xsl if parent name
I asked a similar question a long time ago (and repeated it when the latest draft came out). I didn't get an aswer then, but was playing with it yesterday and worked out a (trivial) solution. You need to be using something which conforms to the latest draft (or supports variables properly). It is also possible to do something non-standard using the MS processor.

XML Fragment:

-----
<area name="foo">
  <page name="index">
  ...
  </page>
  <page name="foo">
  ...
  </page>
</area>
-----

XSL Fragment:

-----
<xsl-template match="page">

<!-- ** The trick is to set a variable, because you can control the context of the variable when you set it -->
<!-- extract the parents "name" -->
<xsl:variable name="parent" expr="from-parent(node())/from-attributes(name)" />

<!-- Now you can compare the current name with the variable. It doesn't matter what context you use because the variable is now set -->
<xsl:if test="from-attributes(name)=$parent">
Found element .....
</xsl:if>

</xsl-template>
-----

Hope this helps. It certainly should work in the latest version of XT, although I might have made an error when I translated it!

Alistair

PS I deliberately used the unified (aka long) syntax to make it clear that it worked only with the new version

>>> James Kerr <james@xxxxxxxxxxxx> 06/07 9:22 pm >>>
Hi,

I am trying to learn XSL and have a question:
How would I form a match statement for an xsl:if that would match a
parent's value with the value of the current element?  In other words, I
have a list of sub-elements and want to determine which element has the
same value as the parent.

Thanks,

-James


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


Current Thread
  • newbie xsl:if
    • James Kerr - Mon, 07 Jun 1999 16:22:57 -0400
      • <Possible follow-ups>
      • Alistair MacDonald - Wed, 09 Jun 1999 11:24:08 +0100 <=

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.