This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: <xsl:if ... question
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: Brian Hickey <brian_hickey1 at yahoo dot com>
- Cc: XSL-List at lists dot mulberrytech dot com
- Date: Tue, 23 Jul 2002 11:21:44 +0100
- Subject: Re: [xsl] <xsl:if ... question
- Organization: Jeni Tennison Consulting Ltd
- References: <20020723095345.5271.qmail@web20808.mail.yahoo.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
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