Re: [xsl] Add an element to the result xml document

Subject: Re: [xsl] Add an element to the result xml document
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Mon, 07 Oct 2002 22:32:20 +0200
Hello Lynda,

hmm, I are copying in the wrong way. From the root context you are copying everything, you should copy node by node. You can read at how identity transformation can look like:

<xsl:template match="@*|node()">
    <xsl:apply-templates select="@*|node()"/>

Then you only need to add further template matching on <MessageID/> and say there, that you want to have it twice in the output:

<xsl:template match="MessageID">
    <xsl:apply-templates select="@*|node()"/>
    <xsl:apply-templates select="@*|node()"/>



LVanvleet@xxxxxxxxxx wrote:
I have sucessfully copied all the elements in source xml to result xml but I
also want duplicates of some elements.  In the partial xml doc below I want
the result to contain two copies of the <MessageID> and </MessageID>

I am using this XSLT:

<?xml version='1.0'?>
<xsl:transform version="1.0"
<xsl:output method="xml" indent="yes"/>

<!-- copy all the elements to the result document -->
<xsl:template match="/">
	<xsl:copy-of select="."/>

<xsl:template match="Order">

<xsl:template match="//ListOfMessageID/MessageID">
<!-- add an extra <MessageID> and </MessageID> element -->
<xsl:element name="MessageID"/>
<xsl:apply-templates select="node()"/>

On a document that starts with the elements:

<?xml version="1.0"?>
<!-- Exostar xCBL 3.0 Order ICD -->

Lynda Van Vleet
E-Procurement Technical Specialist

Newark Electronics
4801 North Ravenswood Avenue
Chicago IL 60640-4496
773 907 5919

XSL-List info and archive:

XSL-List info and archive:

Current Thread