|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: name of a template
Hi Carmelo,
> Is it possible to simulate the equivalent of an enumerated list in XSLT
> (or any other list), then traverse the list and find the attributes that
> way?,
> Am I climbing the wrong tree by looking at that approach?
Ahh, no, you're onto something there :)
If you have your attribute sets defined as normal:
<xsl:attribute-set name="property1">
<xsl:attribute name="foo">...</xsl:attribute>
...
</xsl:attribute-set>
<xsl:attribute-set name="property2">
...
</xsl:attribute-set>
Then you can access them through the document() function. To get at
the 'property1' attribute set, for example, you can use:
document('')/*/xsl:attribute-set[@name = 'property1']
Now because you've got the name as a string, then if you have stored
the position of the current node in a variable:
<xsl:variable name="position" select="position()" />
then you can access the relevant attribute set using:
document('')/*/xsl:attribute-set
[@name = concat('property', $position)]
You can then iterate over the attributes in this attribute set, adding
the attributes:
<xsl:for-each select="document('')/*/xsl:attribute-set
[@name = concat('property',
$position)]/xsl:attribute">
<xsl:attribute name="@name">
<xsl:value-of select=".">
</xsl:attribute>
</xsl:for-each>
The big problem with this solution is that it won't work if the
attribute in the attribute set is defined with anything but a simple
value: if you have an xsl:choose or whatever to decide what the value
is, then the above won't work.
Nice idea :)
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
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








