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
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format