|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] xsl:attribute-set and xsl:use-attribute-sets
Can anyone find the flaw in the code below? I can't seem to get the attribute
set to work at all. As you can see I'm trying several combinations but none
work.
Also, how complicated can the setting of the actual attributes be? For example,
if I wanted to set the BGCOLOR based on position of the 'row', can I simply put
that logic within the definition of the attributes or must attribute values
inside a set be constant? I used to do this in a named template but I think
this approach is cleaner (once it works !). I'm using XT versions April and
August if that matters.
Thanks in advance,
Larry Mason
i2 Technologies
XML
<data>
<row>
<column>1</column>
<column>2</column>
<column>3</column>
</row>
<row>
<column>4</column>
<column>5</column>
<column>6</column>
</row>
</data>
XSL
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
xmlns:"http://www.w3.org/TR/REC-html40"
result-ns="">
<xsl:attribute-set name="tablerow">
<xsl:attribute name="bgcolor">red</xsl:attribute>
</xsl:attribute-set>
<xsl:template match="data">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="row">
<TR xsl:use-attribute-sets="tablerow">
<TR use-attribute-sets="tablerow">
<xsl:element name="TR" xsl:use-attribute-sets="tablerow">
<xsl:element name="TR" use-attribute-sets="tablerow">
<xsl:apply-templates>
</xsl:element>
</xsl:element>
</TR>
</TR>
</xsl:template>
<xsl:template match="column">
cell #<xsl:value-of select="position()"/>=<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
RESULT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<TR use-attribute-sets="tablerow">
<TR use-attribute-sets="tablerow">
<TR>
<TR>
cell #1=1
cell #2=2</TR>
</TR>
</TR>
</TR>
<TR use-attribute-sets="tablerow">
<TR use-attribute-sets="tablerow">
<TR>
<TR>
cell #1=4
cell #2=5</TR>
</TR>
</TR>
</TR>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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








