This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]