xsl-list
[Top] [All Lists]

Re: [xsl] Dumb Question - XML to XML changing only a few values

2007-12-03 02:55:47
On 01/12/2007, Mukul Gandhi <gandhi(_dot_)mukul(_at_)gmail(_dot_)com> wrote:
On 12/1/07, G. Ken Holman <gkholman(_at_)cranesoftwrights(_dot_)com> wrote:
<xsl:template match="a">
  <xsl:copy>12345</xsl:copy>
</xsl:template>

Somehow, I would have preferred ...

<xsl:template match="a">
  <xsl:copy>
    <xsl:text>12345</xsl:text>
  </xsl:copy>
</xsl:template>

But Ken's choice taught me something new :)

Your choice would be the neater option if <a> had any attributes that
you needed copied, eg:

<xsl:template match="a">
 <xsl:copy>
   <xsl:copy-of select="@*"/>
   <xsl:text>12345</xsl:text>
 </xsl:copy>
</xsl:template>

or possible more future proof in case you ever need to override the copy:

<xsl:template match="a">
 <xsl:copy>
   <xsl:apply-templates select="@*"/>
   <xsl:text>12345</xsl:text>
 </xsl:copy>
</xsl:template>




cheers
-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>