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

Re: conditional display of content

Subject: Re: conditional display of content
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Tue, 27 May 2008 10:12:07 +0100
Re:  conditional display of content
2008/5/27 Ganesh Babu N <nbabuganesh@xxxxxxxxx>:
> This is the XML file:

horrible sample XML fragment by the way... what's wrong with indenting it?

> My requirement is to display the corresponding the role/personname in
> the speaker tag. The condition is id and href should match.
> <xsl:template match="pbl:roleref>
>      <xsl:if test="substring-after(@href),#) =
> //pbl:castmember/pbl:role/@xml:id">
>            <xsl:value-of select="//pbl:castmember/pbl:role/personname"/>
>      </xsl:if>
> </xsl:template>

Your xpath needs to at least be //pbl:castmember/pbl:role[$id =

where $id is a variable defined before the select as:

substring-after(@href), '#')    (notice the single quotes around the
hash... or "pound" sign if you speak American)

or just use substring-after(current()/@href), '#') directly in the XPath.

Ultimately though this should be rewritten to use a key:

<xsl:key name="role-by-id" match="pbl:role" use="@xml:id"/>

and then just

<xsl:template match="pbl:roleref>
  <xsl:value-of select="key('role-by-id', substring-after(@href, '#'))"/>

If the lookup value doesn't exist in the key then nothing is returned.

Andrew Welch
Kernow: http://kernowforsaxon.sf.net/

Current Thread


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.
First Name
Last Name
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.