Convert one xml to another XSLT

Hi,

I want to convert xml in one format into another xml format shown below using java or any utility which can be used with JAVA (like XSLT)

Input xml :

<Name>

<Name1>

<Name11>Name11</Name11>

<Name12>Name12</Name12>

</Name1>

<Name1>

<Name11>Name21</Name11>

<Name12>Name22</Name12>

</Name1>

<Name2>

<Name1>

<Name11>Name11</Name11>

<Name12>Name12overRide</Name12>

</Name1>

<Name3>

<Name31>Name3Override</Name31>

</Name3>

</Name2>

<Name3>

<Name31>Name3Origional</Name31>

</Name3>

<Name3>

<Name32>Name3Origional</Name32>

</Name3>

</Name>

Output xml

<Name>

<Name1>

<Name11>Name11</Name11>

<Name12>Name12overRide</Name12>

</Name1>

<Name1>

<Name11>Name21</Name11>

<Name12>Name22</Name12>

</Name1>

<Name2>

</Name2>

<Name3>

<Name31>Name3Override</Name31>

</Name3>

<Name3>

<Name32>Name3Origional</Name32>

</Name3>

</Name>

Basically, Name2 tags stores Overriden information for the tag which are already present inside Name root tag.

i want generic template which does this replacing node based on pre - comparision.

i just know like Name2 is the only tag which stores overRiding information for Node's child tag.

Scenario :

1. While replacing \\Name\Name1 tag, i just know like i have to compare \\Name\Name2\Name1\Name11 with \\Name\Name1\Name11,

If this value matches, i need to replace \\Name\Name1 tag with \\Name\Name2\Name1 tag.

Also only \\Name\Name1 tag which satisfies this condition will replace, all other \\Name\Name1 tags remain same.

2. While replacing \\Name\Name3, i just know like i have to compare \\Name\Name2\Name3\Name31 with \\Name\Name3\Name31,

If this value matches, i just have to replace that \\Name\Name3 node with \\Name\Name2\Name3.

3. This replacing this should be cut paste kind of thing, not copy paste.

Please help me to find its solution,

Please Reply.

[2502 byte] By [nikhil.rastogia] at [2007-11-27 8:11:05]
# 1
There is a xml transform package in the jdk. Maybe that's what you're looking for: http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/transform/package-summary.html-Puce
Pucea at 2007-7-12 19:54:56 > top of Java-index,Java Essentials,Java Programming...
# 2
Look up Apache FOP http://xmlgraphics.apache.org/fop/
blackmagea at 2007-7-12 19:54:56 > top of Java-index,Java Essentials,Java Programming...
# 3
FOP produces PDF. The question was to transform XML to XML. For that you would use XSLT and not XSL-FO (of which FOP is an implementation).
DrClapa at 2007-7-12 19:54:56 > top of Java-index,Java Essentials,Java Programming...
# 4
and for that, use Xalan.
jwentinga at 2007-7-12 19:54:56 > top of Java-index,Java Essentials,Java Programming...