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

Dirty Input

Subject: Dirty Input
From: "Khorasani, Houman" <Houman.Khorasani@xxxxxxxxxxxx>
Date: Thu, 20 Jul 2006 11:29:43 +0100
 Dirty Input
Hello,

Our system is generating some very dirty XML input. I am not sure if
there would be any solution to this problem at all.  At first it might
remind you of my similar request from last week. But this time the
elements are not that conveniently grouped into one parent tag but are
rather loose.

The tag <Devices> contains elements <a>, <b> and <c> in that order
respectively.  The elements <b> and <c> incl. their sub elements are
optional and may be not in the input file. But <a> is mandatory and
would always be in the input file.

The output shall give the exact structure as the input file but group
<a>, <b> and <c> together and put a <device> tag between each group.
Since <a> is mandatory we could take it as a base and say the first <a>
is in the first group and the following tags until the next <a> belong
to group 1 as well.  The next <a> belongs to group 2 and any following
tags until the next <a> shall be in group 2 as well, etc.  Each group
shall be separated by a <device> tag. Otherwise the same structure of
the input file shall be copied.

 Input file:

<bla>x</bla>
<bla>x</bla>
<Devices>
	<a>
		<a2>1</a2>
	</a>
	<b>
		<b2>
			<b3>1</b3>
			<b4>1</b4>
		</b2>
		<b2i>
			<b3i>1</b3i>
			<b4i>1</b4i>
		</b2i>
		...
	</b>
	<c>1</c>
	<a>
		<a2>1</a2>
	</a>
	<b>
		<b2>
			<b3>1</b3>
			<b4>1</b4>
		</b2>
		<b2i>
			<b3i>1</b3i>
			<b4i>1</b4i>
		</b2i>
		...
	</b>
	<c>1</c>
	...
</Devices>

Output:

<bla>x</bla>
<bla>x</bla>
<Devices>
	<device>
		<a>
			<a2>1</a2>
		</a>
		<b>
			<b2>
				<b3>1</b3>
				<b4>1</b4>
			</b2>
			<b2i>
				<b3i>1</b3i>
				<b4i>1</b4i>
			</b2i>
			...
		</b>
		<c>1</c>
	</device>
	<device>
		<a>
			<a2>1</a2>
		</a>
		<b>
			<b2>
				<b3>1</b3>
				<b4>1</b4>
			</b2>
			<b2i>
				<b3i>1</b3i>
				<b4i>1</b4i>
			</b2i>
			...
		</b>
		<c>1</c>
	</device>
	...
</Devices>


Do you guys think this would be possible at all?

Many Thanks,
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.