[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] copy of attributes


Subject: Re: [xsl] copy of attributes
From: "Andrey V. Elsukov" <elsukov@xxxxxxxxxxxx>
Date: Thu, 21 Oct 2004 12:48:40 +0400

Hi, news@xxxxxxxxxxx,

Thursday, October 21, 2004, 12:41:52 PM:
nsd> Hello List,

nsd> I want to performe a copy of an nodesets attributes. I can'nt use
nsd> xsl:copy-of, because I dont want to copy all the child nodes. Is it possible
nsd> to do this? Or do I have to copy each attribute manually by doing something
nsd> like this: 

nsd> <node>
nsd>   <xsl:attribute name="attr"><xsl:value-of
nsd> select="@attr"/></xsl:attribute>
nsd> </node>
For example:

<xsl:template name="attributes">
      <xsl:for-each select="attribute::*">
        <xsl:attribute name="{name()}">
              <xsl:value-of select="self::node()"/>
        </xsl:attribute>
      </xsl:for-each>
</xsl:template>

<xsl:template match="node">
 <node>
  <xsl:call-template name="attributes"/>
 </node>
</xsl:template>

--
Best regards,
Andrey V. Elsukov


Current Thread