Re: [xsl] name of a template

Subject: Re: [xsl] name of a template
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 18 Jan 2001 19:44:45 +0000
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 name="property2">

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:

    [@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',
    <xsl:attribute name="@name">
       <xsl:value-of select=".">

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 :)



Jeni Tennison

 XSL-List info and archive:

Current Thread