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 |
<xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template>
<xsl:template match="MessageID"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template>
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Add an element to the result , LVanvleet | Thread | RE: [xsl] Add an element to the res, Michael Kay |
Re: [xsl] data structure in xslt?, Joerg Heinicke | Date | RE: [xsl] get immediat preceeding n, Liao, John Teguh (Jo |
Month |