I am trying to merge multiple XML files into one in the following manner:
Say I have an XML file, called fruit.xml
:
<fruit>
<apples>
<include ref="apples.xml" />
</apples>
<bananas>
<include ref="bananas.xml" />
</bananas>
<oranges>
<include ref="oranges.xml" />
</oranges>
</fruit>
and subsequent XML files that are referenced from fruit.xml
, like for example apples.xml
:
<fruit>
<apples>
<apple type="jonagold" color="red" />
<... />
</apples>
</fruit>
and so on... I would like to merge these into 1 XML file, like such:
<fruit>
<apples>
<apple type="jonagold" color="red" />
<... />
</apples>
<bananas>
<banana type="chiquita" color="yellow" />
<... />
</bananas>
<oranges>
<orange type="some-orange-type" color="orange" />
<... />
</oranges>
</fruit>
I want to determine the "child" files (like apples.xml
, bananas.xml
, etc.) dynamically based on the values of the ref
attributes in the <include>
elements of fruits.xml
and then include them in the output.
Is this possible using XSLT?