Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSLT copying and enriching

Reply
Thread Tools

XSLT copying and enriching

 
 
olivier.scalbert@algosyn.com
Guest
Posts: n/a
 
      01-26-2007
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

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      01-26-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) 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/
 
Reply With Quote
 
 
 
 
olivier.scalbert@algosyn.com
Guest
Posts: n/a
 
      01-29-2007
Martin,

Thanks very much, it works !

Olivier

On Jan 26, 4:51 pm, Martin Honnen <(E-Mail Removed)> 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/


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
copying all but one type of Nodes in XSLT Wizfrog XML 5 07-14-2007 09:16 PM
Copying xml declaration with XSLT Dennis Benzinger XML 5 07-18-2006 01:56 PM
copying all attributes in XSLT R XML 4 03-11-2005 04:18 PM
ANN: New low-cost XML Editor, XSLT Editor, XSLT Debugger, DTD/Schema Editor Stylus Studio Java 0 08-03-2004 03:53 PM
[XSLT]Passing values from Javascript to a XSLT variable Benjamin Hillsley XML 3 09-25-2003 04:50 AM



Advertisments