XSL & XML comments?

Discussion in 'XML' started by chris, Jul 29, 2003.

  1. chris

    chris Guest

    Hi,

    Is it possible to preserve comments in XSL? I would like to take a XML
    document and merge it with another, but comments and text are not
    copied, only elements and their values.

    Any ideas?


    Cheers,
    Chris
     
    chris, Jul 29, 2003
    #1
    1. Advertising

  2. chris

    chris Guest

    chris wrote:
    > Any ideas?


    Found this snippet on the web eventually!

    <!-- pass unrecognized nodes along unchanged -->
    <xsl:template match="node()|@*">
    <xsl:copy>
    <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
    </xsl:template>
     
    chris, Jul 30, 2003
    #2
    1. Advertising

  3. chris

    Mike Brown Guest

    Yeah, that code is called the identity transformation, and it comes from the
    XSLT spec -- the section titled "copying".
    http://www.w3.org/TR/REC-xslt
    There's all kinds of interesting stuff in there. :)

    "chris" <> wrote
    > Found this snippet on the web eventually!
    >
    > <!-- pass unrecognized nodes along unchanged -->
    > <xsl:template match="node()|@*">
    > <xsl:copy>
    > <xsl:apply-templates select="node()|@*"/>
    > </xsl:copy>
    > </xsl:template>
    >
     
    Mike Brown, Aug 3, 2003
    #3
  4. chris

    Dean Tiegs Guest

    chris <> writes:

    > Is it possible to preserve comments in XSL? I would like to take a
    > XML document and merge it with another, but comments and text are
    > not copied, only elements and their values.


    <xsl:template select="comment()">
    <xsl:copy/>
    </xsl:template>

    --
    Dean Tiegs, NE¼-20-52-25-W4
    “Confortare et esto robustusâ€
    http://telusplanet.net/public/dctiegs/
     
    Dean Tiegs, Aug 6, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. terry
    Replies:
    0
    Views:
    402
    terry
    Jul 9, 2003
  2. Replies:
    1
    Views:
    3,690
    A. Bolmarcich
    May 27, 2005
  3. Replies:
    0
    Views:
    1,182
  4. Monk
    Replies:
    10
    Views:
    1,543
    Michael Wojcik
    Apr 20, 2005
  5. Replies:
    4
    Views:
    650
    Dr John Stockton
    Jun 3, 2006
Loading...

Share This Page