I am trying to address the following problem:
Using a input xml file, source.xml, which has several elements:
<stuff>
<videos>
</videos>
<books>
<book name="book1"/>
</books>
</stuff>
I am trying to take the book name attribute for each book defined, and then add it as a media to a target file donations.xml, which is formatted:
<donations>
<clothes>
</clothes>
<media>
<media name="media1" type="media1" reference="donation">
</media>
</donations>
So, using this input file source.xml, the output file donations.xml should now look like: Note that media type always matches media name, and reference is always donation for my purposes:
<donations>
<clothes>
</clothes>
<media>
<media name="media1" type="media1" reference="donation">
<media name="book1" type="book1" reference="donation">
</media>
</donations>
Any ideas how to do this via XSLT? I think I have to create a template based on the input source.xml using XSL, and then use another XSLT using this template and donations.xml to add the elements.. thoughts? I tagged ant to see if XSLT wasn't a good way to accomplish this..
A bit urgent so would appreciate any ideas!
<stuff>
<videos>
</videos>
<book name="book1"/>
</books>
</stuff>
http://www.w3schools.com/xml/default.asp