|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Conditionally use attribute sets?
It can be done. Consider the following stylesheet (which you can test by
applying it to itself):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="2.0" omit-xml-declaration="no"
indent="yes"/>
<xsl:param name="who"/>
<xsl:attribute-set name="Oscar">
<xsl:attribute name="slob">yes</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="Felix">
<xsl:attribute name="slob">no</xsl:attribute>
</xsl:attribute-set>
<xsl:template match="/">
<bachelor>
<xsl:choose>
<xsl:when test="$who='Oscar'">
<xsl:attribute name="xsl:use-attribute-sets">
<xsl:value-of select="'Oscar'"/>
</xsl:attribute>
</xsl:when>
<xsl:when test="$who='Felix'">
<xsl:attribute name="xsl:use-attribute-sets">
<xsl:value-of select="'Felix'"/>
</xsl:attribute>
</xsl:when>
</xsl:choose>
</bachelor>
</xsl:template>
</xsl:stylesheet>
I tested that with Xalan Java 2.4.1
It's easier in 2.0 because
<xsl:attribute name="xsl:use-attribute-sets">
<xsl:value-of select="'Oscar'"/>
</xsl:attribute>
can be
<xsl:attribute name="xsl:use-attribute-sets" select="'Oscar'"/>
I tested that with Saxon 8.5.1.
Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)
|
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
|

Cart








