Filtering most out of XML with XSL?
Posted
by Gnudiff
on Stack Overflow
See other posts from Stack Overflow
or by Gnudiff
Published on 2009-04-10T15:11:06Z
Indexed on
2010/05/11
4:04 UTC
Read the original article
Hit count: 319
I need to transform a lot of XML files (Fedora export) into a different kind of XML. Trying to do it with XSL stylesheets and checking with the msxsl transformer.
Supposedly I have xml file like this (assuming there are actually other nodes inside AAA, OBJ, amd all other nodes), Source.XML:
<DOC>
<AAA>
<STUFF>example</STUFF>
<OBJ>
<OBJVERS id="A1" CREATED="2008-02-18T13:28:08.245Z"/>
<OBJVERS id="A2" CREATED="2008-02-19T10:42:41.965Z"/>
<OBJVERS id="A13" CREATED="2009-03-16T12:43:11.703Z"/>
</OBJ>
</AAA>
<FFF/>
<GGG/>
<DDD>
<FILE />
</DDD>
</DOC>
Which I need to look something like this (Target.XML):
<MYOBJ>
<ELEM>contents of OBJVERS with the biggest id OR
creation date (whichever is easier to do) go here</ELEM>
<IMAGE> contents of <FILE> node go here</IMAGE>
</MYOBJ>
The main problem that I have is that since I am new to XSL (and for this particular task do not have enough time to learn it properly) is that I can't understand how to tell XSL processor not to process anything else, I keep getting output from , for example.
Update: basically, I solved this problem meanwhile. I will post my own answer and close the question.
Update2: OK, Andrew's answer works, too, so I am just accepting it. :)
© Stack Overflow or respective owner