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]

Copying node but changing attributes


Hi all,

   Here is my most recent problem: I want to copy nodes from the input
xml to the output xml but I want to change the contents of some of
their attributes. I found the following little template in Michael
Kay's book:

<xsl:template match="node">
  <xsl:copy>
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

This template copies node plus their attributes. Now I thought
could modify the template but somehow I am stuck. I thought I
could loop over the attributes. But how do I change them. To give you
an example, some of the atributes contain placeholders. I want
to replace those with real data. How would I do this? Would the
following concept work? And how would I be able to change the 
attributes? Would the xsl:copy copy the changed attributes?

<xsl:template match="node">
  <xsl:copy>
    <xsl:for-each select="@*">
      <!-- DO SOMETHING WITH ATTR -->
      <xsl:copy/>
    </xsl:for-each>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

Thanks for any help on this!

- Joerg
________________________________
Dr Joerg M Colberg
Econovo Software, Inc
joerg.colberg@econovo.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]