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

change element to sibling's child node

Subject: change element to sibling's child node
From: "Lin, Jessica" <jlin@xxxxxxxxxxx>
Date: Mon, 21 Aug 2006 13:32:36 -0700
xml change element
I need to do xml to xml transform. Here is my problem. Could you please
give me the help?



Original XML file:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint>
	<co>
		<co_body>
			<source_id>100</source_id>

			<CGMS_indicator>0</CGMS_indicator>
			<c_PIP_indicator>0</c_PIP_indicator>
			<c_definition>
				<service_type>100</service_type>
				<HTTP_indicator>0</HTTP_indicator>
				<number_of_streams>2</number_of_streams>
				<root_ID>100</root_ID>
				<stream_loop>
					<stream_definition>

<stream_type>2</stream_type>
						<SCID>100</SCID>

<descriptors_loop_length>compute</descriptors_loop_length>
						<descriptor_loop>

<about_descriptor>some description</about_descriptor>

<additional_descriptor>other description</additional_descriptor>
						</descriptor_loop>
					</stream_definition>
				</stream_loop>
			</c_definition>
		</co_body>
	</co>
</blueprint>




Need to do following transforms:

move CGMS_indicator and its text value under c_definition
in c_definition:
	add new element called PCR_PID_indicator, the text value equals
to the PID value of first stream in stream loop
	calculate stream number which start from root_ID and end with
root_ID+ number_of_streams, the gap is 1
	copy descriptors_loop_length and descriptor_loop from
c_definition\stream_loop\stream_definition to c_definition
in stream_loop
	rename stream_definition to stream
	recursive create stream element number_of_streams times
in each stream i:
	rename SCID to PID, the text value equals 4112+2*i
	add new element called ECM, the text value equals PID+1


the result XML file:

<?xml version="1.0" encoding="UTF-8"?>
<blueprint>
	<co>
		<co_body>
			<source_id>100</source_id>

			<c_PIP_indicator>0</c_PIP_indicator>
			<c_definition>
				<service_type>100</service_type>
				<CGMS_indicator>0</CGMS_indicator>

<PCR_PID_indicator>4112</PCR_PID_indicator>
				<HTTP_indicator>0</HTTP_indicator>
				<number_of_streams>2</number_of_streams>
				<root_ID>100</root_ID>
				<stream_loop>
					<stream>

<stream_type>2</stream_type>
						<PID>4112</PID>
						<ECM>4113</ECM>

<descriptors_loop_length>compute</descriptors_loop_length>
						<descriptor_loop>

<about_descriptor>some description</about_descriptor>

<additional_descriptor>other description</additional_descriptor>
						</descriptor_loop>
					</stream>
					<stream>

<stream_type>2</stream_type>
						<PID>4114</PID>
						<ECM>4115</ECM>

<descriptors_loop_length>compute</descriptors_loop_length>
						<descriptor_loop>

<about_descriptor>some description</about_descriptor>

<additional_descriptor>other description</additional_descriptor>
						</descriptor_loop>
					</stream>

				</stream_loop>
			</c_definition>

<descriptors_loop_length>compute</descriptors_loop_length>
			<descriptor_loop>
				<about_descriptor>some
description</about_descriptor>
				<additional_descriptor>other
description</additional_descriptor>
			</descriptor_loop>
		</co_body>
	</co>
</blueprint>




Thanks,

Jesscia

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.