[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl]
Re: [xsl]
Subject: Re: [xsl] <xsl:if ... question
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 23 Jul 2002 11:21:44 +0100
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
- [xsl] <xsl:if ... question
- Brian Hickey - Tue, 23 Jul 2002 02:53:45 -0700 (PDT)
- Jeni Tennison - Tue, 23 Jul 2002 11:21:44 +0100 <=
- David Carlisle - Tue, 23 Jul 2002 11:21:57 +0100
<- Previous Index Next ->
[xsl] <xsl:if ... question, Brian Hickey
Thread
Re: [xsl] <xsl:if ... question, David Carlisle
[xsl] variable with node in xsl:cho, inchi2000
Date
Re: [xsl] <xsl:if ... question, David Carlisle
Month
Subject: Re: [xsl] <xsl:if ... question From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Tue, 23 Jul 2002 11:21:44 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] <xsl:if ... question, Brian Hickey | Thread | Re: [xsl] <xsl:if ... question, David Carlisle |
[xsl] variable with node in xsl:cho, inchi2000 | Date | Re: [xsl] <xsl:if ... question, David Carlisle |
Month |