[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: name of a template

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.