XSLT copying and enriching

Discussion in 'XML' started by olivier.scalbert@algosyn.com, Jan 26, 2007.

  1. Guest

    Hello,

    How can I write the XSLT to transform:

    <Root>
    <Element attribute="value"/>
    <Element2>
    <Element3/>
    </Element2>
    </Root>

    into:

    <Root>
    <Element attribute="value"/>
    <Element2>
    <Element3/>
    </Element2>
    <New element>
    ....
    </New element>
    </Root>

    The output is the same as the input with a new element at the end.

    Thanks for your help.
    Olivier
     
    , Jan 26, 2007
    #1
    1. Advertising

  2. wrote:

    > How can I write the XSLT to transform:
    >
    > <Root>
    > <Element attribute="value"/>
    > <Element2>
    > <Element3/>
    > </Element2>
    > </Root>
    >
    > into:
    >
    > <Root>
    > <Element attribute="value"/>
    > <Element2>
    > <Element3/>
    > </Element2>
    > <New element>
    > ....
    > </New element>
    > </Root>
    >
    > The output is the same as the input with a new element at the end.


    Start with the identity transformation template
    <xsl:template match="@* | node()">
    <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
    </xsl:template>
    then add
    <xsl:template match="Root">
    <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
    <New-Element>
    ....
    </New-Element>
    </xsl:copy>
    </xsl:template>

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jan 26, 2007
    #2
    1. Advertising

  3. Guest

    Martin,

    Thanks very much, it works !

    Olivier

    On Jan 26, 4:51 pm, Martin Honnen <> wrote:
    > Start with the identity transformation template
    > <xsl:template match="@* | node()">
    > <xsl:copy>
    > <xsl:apply-templates select="@* | node()"/>
    > </xsl:copy>
    > </xsl:template>
    > then add
    > <xsl:template match="Root">
    > <xsl:copy>
    > <xsl:apply-templates select="@* | node()"/>
    > <New-Element>
    > ....
    > </New-Element>
    > </xsl:copy>
    > </xsl:template>
    >
    > --
    >
    > Martin Honnen
    > http://JavaScript.FAQTs.com/
     
    , Jan 29, 2007
    #3
    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. Stylus Studio
    Replies:
    0
    Views:
    684
    Stylus Studio
    Aug 3, 2004
  2. Benjamin Hillsley
    Replies:
    3
    Views:
    1,689
    Dimitre Novatchev
    Sep 25, 2003
  3. R
    Replies:
    4
    Views:
    2,964
    Joris Gillis
    Mar 11, 2005
  4. Dennis Benzinger

    Copying xml declaration with XSLT

    Dennis Benzinger, Jul 13, 2006, in forum: XML
    Replies:
    5
    Views:
    1,414
    Dennis Benzinger
    Jul 18, 2006
  5. Wizfrog
    Replies:
    5
    Views:
    2,292
    Joe Kesselman
    Jul 14, 2007
Loading...

Share This Page