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

RE: XSL : template for attribute

Subject: RE: XSL : template for attribute
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Thu, 29 Apr 1999 10:52:41 +0100
RE: XSL : template for attribute
> 
> 2. If I tried to write template for this attribute ,
> it doesn't work correctly - it each time goes  to the " 
> otherwise" case  .
> What wrong here ?
> > 
> <xsl:template match="@colr">
>  <xsl:attribute name="STYLE">color:
>    <xsl:choose>
>         <xsl:when test="@colr[.='2']">white</xsl:when >
>         <xsl:when test="@colr[.='0']">green</xsl:when >
>         <xsl:otherwise >black</xsl:otherwise >
>    </xsl:choose>
>    </xsl:attribute>
> </xsl:template>
> 
There's a lot of differences as to the exact form of the condition in
<xsl:when>. In the Dec 1998 standard it's a select-pattern (returning true
if any nodes are selected), but other options are suggested in editorial
notes. In Apr 99 it's a boolean-expression. In SAXON 4.2 it's a match
pattern (true if the current node matches).

Your test fails as a select-expression because it's asking to find an @colr
attribute of the @colr attribute, and attributes don't have attributes. It
would work in SAXON, I think. In the April 99 spec you should write:
test=".='2'"

(Incidentally, I can't see an easy way in the April 99 spec to test in a
boolean expression whether the current node matches a match-pattern. I would
have thought it would be useful to allow something like:

<xsl:if test="matches(CHAPTER[TITLE]//PARA)">

to test whether the node is a PARA with a CHAPTER ancestor that has a TITLE
child.
In SAXON I made the test a match pattern because a match pattern can refer
to a select pattern but not the other way round.);

Mike Kay


 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.