RE: [xsl] XML copy transformation

Subject: RE: [xsl] XML copy transformation
From: "WATKIN-JONES,ADAM (HP-UnitedKingdom,ex1)" <adam_watkin-jones@xxxxxx>
Date: Wed, 20 Mar 2002 16:48:52 -0000
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: [xsl] 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