473,394 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

XSLT copying and enriching

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 '07 #1
2 1280
ol**************@algosyn.com 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/
Jan 26 '07 #2
Martin,

Thanks very much, it works !

Olivier

On Jan 26, 4:51 pm, Martin Honnen <mahotr...@yahoo.dewrote:
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 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Sarah Haff | last post by:
Hi, What would be minimilistic XSLT that does "nothing" (no transformation) to the given XML content. Thank you. Sarah Haff
4
by: cyclops | last post by:
I'm trying to do XML + XSLT -> Another XML. The source XML contains multiple namespaces and XSLT will handle all possible tags under each name space. ----source---- <document xmlns="..."...
12
by: Keith Chadwick | last post by:
I have a fairly hefty XSLT file that for the sake of debugging and clarity I wish to split into some separate sub-templates contained within the same file. The master template calls an...
3
by: Stephan Brunner | last post by:
Hi I have created two flavors of an XSLT stylesheet to transform all attributes of an XML document to elements: They both work as expected with MSXML and XMLSPY but throw an exception ...
1
by: Dan | last post by:
I have a C# program which executes some XSLT transformations. The XSLT code requires an input intermediate file, generated by other transformations, as its duty is copying some data from an input...
43
by: Tim Chase | last post by:
Just as a pedantic exercise to try and understand Python a bit better, I decided to try to make a generator or class that would allow me to unpack an arbitrary number of calculatible values. In...
9
by: starlight | last post by:
Hallo, there were some posts about this, but nothing I could find useful. I have a large XML file (80MB) and need certain information out of it. I though I could use XSLT with an fairy simple...
3
by: WideBoy | last post by:
Hi, I have a software generated schema which creates a few empty elements, e.g. <xsd:sequence/>. I would like to be able to delete these elements from the schema post-generation using XSLT. ...
6
by: kluge.wolfram | last post by:
Hi, i get stucked on a transformation problem using XSLT. What i need is to copy an XML Tree to an output XML without any automatic changes. Since i used <xsl:copyor <xsl:copy-ofthere occur...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.