Re: [xsl] change a list of attribute name

Subject: Re: [xsl] change a list of attribute name
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 3 Aug 2001 15:31:05 +0100
Hi Xiaocun,

> I have a header which consisted of normal names such as "Last Name".
> For each of these, I would like to replace it with a valid XML
> attribute name such as LastName. What would be the best way to do
> it?

Remember that the name attribute of xsl:attribute can hold an
attribute value template, so you can compute the value for the
attribute name dynamically and use that. For example, if you only need
to get rid of spaces, then using translate() would probably be your
best bet:

  <xsl:for-each select="$header/cell">
    <xsl:attribute name="{translate(., ' ', '')}">
       ...
    </xsl:attribute>
  </xsl:for-each>

If you can compute the names that you need to populate a node set,
then you can compute them directly within the xsl:for-each, so I don't
think that you will have to use an intermediate node set at all.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread