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

Re: <xsl:if ... question

Subject: Re: <xsl:if ... question
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 23 Jul 2002 11:21:44 +0100
Re:  <xsl:if ...  question
Hi Brian,

> Basically I want to test if the value of the
> identifierref attribute in the item element, is equal
> to the identifier attribute, in the resource element.

Presumably there might be a lot of resource elements with different
identifiers? If so, it's probably easiest to create a key that indexes
the resource elements by their identifiers as follows:

<xsl:key name="resources" match="resource" use="@identifier" />

You can then get a particular resource based on its identifier with:

  key('resources', $identifier)

So, for example, if you're on an item element at the moment, you can
get the resource referenced by that item element's identifierref
attribute using:

  key('resources', @identifierref)

I'd store that resource in a variable and then test whether the
variable contains anything:

<xsl:template match="item">
  <xsl:variable name="resource"
                select="key('resources', @identifierref)" />
  <xsl:if test="$resource">
    ...
  </xsl:if>
</xsl:template>
  
> If so, then I want to take the value of the href attribute from the
> resource element and use it to create a link in my html document,
> along with the content of the title element, which will be the name
> of the link.

You should find this easy enough. The resource element's href
attribute can be accessed with $resource/@href.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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.