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

RE: Navigating an XML file with xsl:for-each etc.

Subject: RE: Navigating an XML file with xsl:for-each etc.
From: "Khorasani, Houman" <houman_khorasani@xxxxxxxxxxxxxx>
Date: Fri, 26 Aug 2005 16:44:08 +0100
delete .xml file
Hi Peter,

Sure.  I try to explain it better this way.  The Input file is a
shopping list. :)

Only if any category has an action attribute called 'change' we would
consider it.

In this case "groceries" and "toys should have to be picked up.
Thereafter it has to be checked if any sub product exists in <add> as
well as in <delete>; in this case <food>Bread</food> has to be in the
final output.


Input:

<electronic action='add'>
	<add>
		<phone>mobile</phone>
	</add>
</electronic>
<groceries action='change'>
	<add>
		<drink>Milk</drink>
		<food>Bread</food>
		<food>fish</food>
	</add>
	<delete>
		<food>Bread</food>
		<drink>wine</drink>
	</delete>
</groceries>
<toys action='change'>
	<add>
		...
	</add>
	<delete>
		...
	</delete>
</toys>

Output:

<modified>
	<food>Bread</food>
	...
</modified>


Hopefully you know what I mean now. :)

Many thanks
Houman


-----Original Message-----
From: Jacoby, Peter R. [mailto:PJACOBY@xxxxxxxxxxxx]
Sent: 26 August 2005 16:02
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Navigating an XML file with xsl:for-each etc.

Houman,

It would help us to help you if you could provide the output XML you are
looking
for.  With the given input and your explanation, it is not clear what
output XML
you want.

-Peter

-----Original Message-----
From: Khorasani, Houman [mailto:houman_khorasani@xxxxxxxxxxxxxx]
Sent: Friday, August 26, 2005 10:54 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Navigating an XML file with xsl:for-each etc.

Hello everyone,

I have checked the FAQ but couldn't find any solution to this:

I have an XML file like this:

<a>
</a>
<b action='change'>
	<add>
		<c>bla</c>
		<d>bla</d>
	</add>
	<delete>
		<c>bla</c>
		<d>bla</d>
	<delete>
</b>
<e>
</e>


I have to check for each attribute called 'change'
	Then look if it has an <add> tag and an <delete> tag
		- Compare the sub element of <add> called <c> with the
sub 			element of <delete> called <c> and see if the
value is equal.
		- The same with sub element <d>


I guess the best to do that is to use a for-each to check all the
attributes with the value 'change' (This is not working in my example
below though)
1) How do I use for-each with attributes? Like this?

<xsl:for-each select="//[action='change']">
		<xsl:if test=".='add'">
			...
		</xsl:if>
		...
</xsl:for-each>

2) How do I compare in the most efficient way the two sub-elements <c>
and <d> against each other?


Many thanks for any idea,
Houman

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.