Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing an XML document using XSL transformations

Status
Not open for further replies.

adk

Programmer
Mar 19, 2001
1
DE
Hi. I have an XML document that I want to perform an XSL transformation on and I'm not sure how to get the results I want. Let me give an example of the original and desired documents.

Code:
Original XML:
<Material_Description Material_ID=&quot;MyVideo&quot;>
	<Volume Material_ID=&quot;MyVideo&quot;>
		<Label>MyVideoFootage</Label>
		<Shot Material_ID=&quot;Shot1&quot;>
			<In_Frame />
			<Out_Frame />

			<Shot Material_ID=&quot;SubShot1a&quot;>
				<In_Frame />
				<Out_Frame />		
			</Shot>

			<Shot Material_ID=&quot;SubShot1b&quot;>
				<In_Frame />
				<Out_Frame />		
			</Shot>
		</Shot>
		<Shot Material_ID=&quot;Shot2&quot;>
			<In_Frame />
			<Out_Frame />
		</Shot>
	<Volume>
</Material_Description>

I'd like to use an XSL transformation to create an EXACT COPY of the original XML document plus a modification in the XML node hierarchy so that if a &quot;SubShot&quot; exists, it replaces its &quot;Shot&quot; parent node.

Desired XML:
Code:
<Material_Description Material_ID=&quot;MyVideo&quot;>
	<Volume Material_ID=&quot;MyVideo&quot;>
		<Label>MyVideoFootage</Label>
		<Shot Material_ID=&quot;SubShot1a&quot;>
			<In_Frame />
			<Out_Frame />
		</Shot>
		<Shot Material_ID=&quot;SubShot1b&quot;>
			<In_Frame />
			<Out_Frame />
		</Shot>
		<Shot Material_ID=&quot;Shot2&quot;>
			<In_Frame />
			<Out_Frame />
		</Shot>
	<Volume>
</Material_Description>

Everything I read about XSL transformations indicates that this should be possible, but I can't work out the syntax to achieve the desired result. I believe I could solve this using a DOM, but I'm very new to XSL and I suspect the XSL solution would be more elegant and extensible. Humble cries for help from an XSL rookie.

Best regards,

ADK.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top