Hi,
I am out of my depth regarding xsl transforms for generating a sample XML file. Basically the process is I am trying to generate a large and complex XML template file from an application generated XSD.
I have used XMLSpy to generate a sample XML file from the XSD my next step is to convert the values to the required values.
example of what I am trying to convert...
<TEST>
<VALUE1>String</VALUE1>
<VALUE1>aaaa</VALUE1>
<VALUE1>aaaaaaaaaaaaa</VALUE1>
</TEST>
<TEST>
<VALUE1>String</VALUE1>
<VALUE1>aaaa</VALUE1>
<VALUE1>aaaaaaaaaaaaa</VALUE1>
</TEST>
into
<TEST>
<VALUE1>TEST_1.VALUE1_1.text</VALUE1>
<VALUE1>TEST_1.VALUE1_2.text</VALUE1>
<VALUE1>TEST_1.VALUE1_3.text</VALUE1>
</TEST>
<TEST>
<VALUE1>TEST_2.VALUE1_1.text</VALUE1>
<VALUE1>TEST_2.VALUE1_2.text</VALUE1>
<VALUE1>TEST_2.VALUE1_3.text</VALUE1>
</TEST>
Any help is greatly appreciated as I'm new to XML transformations.
Thank you for you feedback, and sorry I wasn't as clear as possible with the request.
In summary I am looking at having some sort of counter for the elements and replacing the value within the XML with the augmented value and count.
i.e. if this is the first time that TEST is found and the first time VALUE1 is found then replace the TAG value with TEST_1.VALUE1_1.text and then repeated throughout the tree structure. So if I have :-
<TEST><VALUE1><SUBVAL1>aaaaa</TEST></VALUE1></SUBVAL1>
then I would look at replacing aaaaaa with TEST_1.VALUE1_1.SUBVAL1_1.text (ignoring the aaaaa because I dont care)
I suppose I will ask two questions here :-
- Is this possible?
- If so would XSLT be the best tool here (if needed I could wrap it with Java and use DOM/SAX to parse and replace - just thought that would be overkill)