[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Add an element to the result xml document

Subject: RE: Add an element to the result xml document
From: LVanvleet@xxxxxxxxxx
Date: Mon, 7 Oct 2002 16:06:22 -0500
add xml node
Joerg,
Thanks for your timely reply.  I understand you technique but that puts an
entire duplicate<MessageID>...</MessageID> following the current
<MessageID>...</MessageID>
I need just of copy of the element <MessageID> following the source
<MessageID> and </Message> following the source </MessageID>
Sorry I wasn't very clear.
Lynda

-----Original Message-----
From: Joerg Heinicke [mailto:joerg.heinicke@xxxxxx]
Sent: Monday, October 07, 2002 3:32 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Add an element to the result xml document


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 
http://www.w3.org/TR/xslt#copying how identity transformation can look like:

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

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:copy>
     <xsl:apply-templates select="@*|node()"/>
   </xsl:copy>
   <xsl:copy>
     <xsl:apply-templates select="@*|node()"/>
   </xsl:copy>
</xsl:template>

Regards,

Joerg


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>
> elements.
> 
> I am using this XSLT:
> 
> <?xml version='1.0'?>
> <xsl:transform version="1.0"
>        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml" indent="yes"/>
> 
> <!-- copy all the elements to the result document -->
> <xsl:template match="/">
> 	<xsl:copy-of select="."/>
> </xsl:template>
> 
> <xsl:template match="Order">
> 	<xsl:apply-templates/>
> </xsl:template>
> 
> <xsl:template match="//ListOfMessageID/MessageID">
> 	<!-- add an extra <MessageID> and </MessageID> element -->
>     <xsl:element name="MessageID"/>
>     <xsl:apply-templates select="node()"/>
>   </xsl:template>
>   
> </xsl:transform>
> 
> On a document that starts with the elements:
> 
> <?xml version="1.0"?>
> <!-- Exostar xCBL 3.0 Order ICD -->
> <Order>
> 	<OrderHeader>
> 		<OrderNumber>
> 			<BuyerOrderNumber>3</BuyerOrderNumber>
> 			<SellerOrderNumber/>
> 			<ListOfMessageID>
> 				<MessageID>
> 					<IDNumber/>
> 					<IDAssignedBy>
> 						<IDAssignedByCoded/>
> 						<IDAssignedByCodedOther/>
> 					</IDAssignedBy>
> 					<IDAssignedDate/>
> 				</MessageID>
> 			</ListOfMessageID>
> 		</OrderNumber>
> 
> 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:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.