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

RE: XML copy transformation

Subject: RE: XML copy transformation
From: "WATKIN-JONES,ADAM (HP-UnitedKingdom,ex1)" <adam_watkin-jones@xxxxxx>
Date: Wed, 20 Mar 2002 16:48:52 -0000
xml copy
How about something like

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="* | @* | text()">
        <xsl:copy>
            <xsl:apply-templates select="* | @* | text()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="Article[../process/@code='upd']/text()">
        <xsl:value-of select="concat('desc. article ', .)"/>
    </xsl:template>
</xsl:stylesheet>



-----Original Message-----
From: progressdll linux [mailto:progressdll.linux@xxxxxxx]
Sent: 20 March 2002 15:31
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  XML copy transformation


To good folk at XLST list;

How can i make a copy of an XML file where i need to replace values bases on
the
fact if a element exist and has a certain value lower down the tree:

ex.

<Order>
	<Orderline linenr="1">
		<Article Type="P">100</Article>
		<process code="upd"/>
	</Orderline>
	<Orderline linenr="2">
		<Article Type="P">510</Article>
		<process code="nop"/>
	</Orderline>
	<Orderline linenr="3">
		<Article Type="P">225</Article>
		<Quant>10</Quant>
		<process code="upd"/>
	</Orderline>
</Order>

Now i want to replace the article element with description of the article 
( should come out of another XML file but lets start with hardcoding first )

And only if the Process code="upd".

Result XML should be

<Order>
	<Orderline linenr="1">
		<Article Type="P">desc. article 100</Article>
		<process code="upd"/>
	</Orderline>
	<Orderline linenr="2">
		<Article Type="P">510</Article>
		<process code="nop"/>
	</Orderline>
	<Orderline linenr="3">
		<Article Type="P">desc. article 225</Article>
		<Quant>10</Quant>
		<process code="upd"/>
	</Orderline>
</Order>

We can leave the process code in the result.
My attempts fail when i arrive at the Orderline node on which i test for the
process code.
( with an xpath of <xsl:when test="Orderline[process[@code='upd']]"> )
But i can't figure out how to process the childeren of the orderline node.

Process code will not always be set and sometimes there are also other
elements extra like
the quant element.

Thanks for any feedback
PG
-----------------------------------------------------
Mail.be, Free WebMail and Virtual Office
http://www.mail.be


 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.