I’m trying to do an xml trasformation with XSLT. I have the following xml:
<myxml>
<dataType1>
<value1>
A1
</value1>
<value2>
A2
</value2>
</dataType1>
<dataType1>
<value1>
B1
</value1>
<value2>
B2
</value2>
</dataType1>
<dataType2>
<value1>
A1
</value1>
<value3>
A3
</value3>
</dataType2>
<dataType2>
<value1>
B1
</value1>
<value3>
B3
</value3>
</dataType2>
each datatype2 has an element value1 that is a foreign key in the datatype2 so then I have to map this data based on the value1.
If exists a dataType1 with value1=A1 and a dataType2 with a value1=A1 then I have to create an xml with the values of value2 and value3 so the result will be the following:
<resultxml>
<data>
<value2>
A2
</value2>
<value3>
A3
</value3>
</data>
<data>
<value2>
B2
</value2>
<value3>
B3
</value3>
</data>
I thought about creating dynamically the variables while reading the dataType1 and then calling them when reading the datatype2 but as I read on some forum that is not possible so my question is: is possible to do what I explained? if yes which is the approach I have to follow (examples are welcome)
thanks in advance
This transformation:
when applied on the provided XML document:
produces the wanted, correct result: