xsl-list
[Top] [All Lists]

Re: [xsl] Variable in XPath

2007-06-27 08:00:23
On 6/27/07, Andrew Welch <andrew(_dot_)j(_dot_)welch(_at_)gmail(_dot_)com> 
wrote:
Seems like a long-winded way of just saying you want to check if <class> exists:

<xsl:when test="doc('factbase.xml')/facts/class">

If you then want to do something specific if the @id eq $id then add a
condition inside the xsl:when.

Or its probably cleaner to just add another when:

<xsl:when test="doc('factbase.xml')/facts/class[(_at_)id eq $id]">
 there is a class with a matching @id
</xsl:when>
<xsl:when test="doc('factbase.xml')/facts/class">
 there are one or more class elements, but none of them a matching @id
</xsl:when>
<xsl:otherwise>
 this aren't any class elements...
</xsl:otherwise>

You'd want to refactor the call to doc() into a variable too.

--
http://andrewjwelch.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>