This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: change a list of attribute name
- To: Xiaocun Xu <xiaocunxu at yahoo dot com>
- Subject: Re: [xsl] change a list of attribute name
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Fri, 3 Aug 2001 15:31:05 +0100
- CC: xsl-list at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <20010803012131.72140.qmail@web11101.mail.yahoo.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
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