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

Re: Clarify Add an element to the result xml document

Subject: Re: Clarify Add an element to the result xml document
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Tue, 08 Oct 2002 19:44:17 +0200
xml repeat
Hello Lynda,

then it's easy:

<xsl:template match="MessageID">
  <xsl:copy>
  <!-- here the copy template is applied only to possible attributes -->
    <xsl:apply-templates select="@*"/>
    <xsl:copy>
      <!-- here the copy template is applied to attributes and nodes -->
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:copy>
</xsl:template>

Regards,

Joerg

LVanvleet@xxxxxxxxxx wrote:
To clarify what I need.
This is source XML:

<Order>
	<OrderHeader>
		<OrderNumber>
			<BuyerOrderNumber>3</BuyerOrderNumber>
			<SellerOrderNumber/>
			<ListOfMessageID>
		<!-- one MessageID element -->
				<MessageID>
					<IDNumber/>
					<IDAssignedBy>
						<IDAssignedByCoded/>
						<IDAssignedByCodedOther/>
					</IDAssignedBy>
					<IDAssignedDate/>
				</MessageID>
			</ListOfMessageID>
		</OrderNumber>

This is what I need the result to look like:

<Order>
	<OrderHeader>
		<OrderNumber>
			<BuyerOrderNumber>3</BuyerOrderNumber>
			<SellerOrderNumber/>
			<ListOfMessageID>
		<!-- nested MessageID elements -->
				<MessageID>
				<MessageID>
					<IDNumber/>
					<IDAssignedBy>
						<IDAssignedByCoded/>
						<IDAssignedByCodedOther/>
					</IDAssignedBy>
					<IDAssignedDate/>
				</MessageID>
				</MessageID>
			</ListOfMessageID>
		</OrderNumber>


The Solution from Michael Kay that follows duplicated the MessageID and children: <xsl:template match="MessageID"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> <!-- and again... --> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template>

The Solutions from Joerg adds a <MessageID/> element in place of the child
elements:
<xsl:template match="MessageID">
    <xsl:copy>
      <xsl:copy>
      </xsl:copy>
    </xsl:copy>
</xsl:template>

The burning question is why do I want this.  We receive E-Procurement orders
in xCBL, cXML, etc.  We set up mapping in NetFish to our order response and
back-end.  When we start a new element map in NetFish (now Iona E2A
Integrator) we repeat element tags to show repeating groups of elements.

Thanks again for your help - I have tried so many ways to solve this without
manually adding the tags.
Lynda

Lynda Van Vleet


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.