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. 🙂
This question has been formulated very loosely and this is not helpful for providing a more meaningful solution.
This said, the below transformation:
when applied on the artificial and contrived provided XML document (that in fact has bad structuring and naming and goes against many principles of designing XML documents):
produces what one could guess is the wanted result: