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

RE: Conditionally use attribute sets?

Subject: RE: Conditionally use attribute sets?
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Mon, 14 Nov 2005 12:07:24 +0200
RE:  Conditionally use attribute sets?
Hi,

>  I'd like to conditionally add an attribute set to an
>element.  Something like this:

You're not the only one :/

>    <xsl:attribute-set name="my.set">
>      <xsl:attribute name="attr">value</xsl:attribute>
>    </xsl:attribute-set>
>
>    <literal-res-elem>
>      <xsl:if test="@condition">
>        <xsl:use-attribute-sets name="my.set"/>
>      </xsl:if>
>    </literal-res-elem>
>
>  But after the recommendation, it seems it's not possible:

No, you can use xsl:choose to generate two literal result elements, one with
the attribute set and one without. If you're into extensions, you can generate
a dummy RLE that has the attribute set, then cast that into a node-set and
then conditionally copy e:node-set($dummy)/*/@* but that's ugly. In some cases
you can stick the test into the xsl:attribute, but in your case it wouldn't
work as that way you can only control the value of the attribute, not the
occurrence. Clearly a case where XSLT forces you to just through few hoops.

Jarno

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.