This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: change a list of attribute name


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]