Hello,
I have an XML with approximately the following structure, the relevant characteristic here the recursive relation of the element pair "F" and "Child_Fs". "Child_Fs" can contain any number of "F" and "F" can contain only one "Child_Fs":
My actual XML doesn't contains IDs, I just wrote them in this example for ilustration purposes.
So what I would like to get after the transformations is the following XML, in which all "F" elements are children of their corresponding highest "F" ancestor. Meaning that the maximal depth for an F element should be of only two occurrances. The other important requirement here is to keep all data (attributes and text inclusive) intact, it is just a relocation operation:
I would appreciate it a lot if anyone could give me a hint on this. Till now I've not been able to come up with a correct XSL Stylesheet.
Many thanks in advance.
I have an XML with approximately the following structure, the relevant characteristic here the recursive relation of the element pair "F" and "Child_Fs". "Child_Fs" can contain any number of "F" and "F" can contain only one "Child_Fs":
Code:
<A>
<B>
<F id="1">
<J/>
<K/>
<Child_Fs>
<F id="1.1">
<J/>
<K/>
<Child_Fs>
<F id="1.1.1">
<J/>
<K/>
<Child_Fs>
...
</Child_Fs>
</F>
<F id="1.1.2">
...
</F>
<F id="1.1.3">
...
</F>
<F id="1.1.4">
...
</F>
.
.
.
</Child_Fs>
</F>
<F id="1.2">
...
</F>
<F id="1.3">
...
</F>
<F id="1.4">
...
</F>
.
.
.
</Child_Fs>
</F>
<F id="2">
...
</F>
<F id="3">
...
</F>
<F id="4">
...
</F>
.
.
.
<G/>
<H/>
<I/>
</B>
<C/>
<D/>
<E/>
</A>
My actual XML doesn't contains IDs, I just wrote them in this example for ilustration purposes.
So what I would like to get after the transformations is the following XML, in which all "F" elements are children of their corresponding highest "F" ancestor. Meaning that the maximal depth for an F element should be of only two occurrances. The other important requirement here is to keep all data (attributes and text inclusive) intact, it is just a relocation operation:
Code:
<A>
<B>
<F id="1">
<J/>
<K/>
<Child_Fs>
<F id="1.1">
<J/>
<K/>
<Child_Fs>
</Child_Fs>
</F>
<F id="1.1.1">
<J/>
<K/>
<Child_Fs>
</Child_Fs>
</F>
...
<F id="1.1.2">
...
</F>
<F id="1.1.3">
...
</F>
<F id="1.1.4">
...
</F>
.
.
.
<F id="1.2">
...
</F>
<F id="1.3">
...
</F>
<F id="1.4">
...
</F>
.
.
.
</Child_Fs>
</F>
<F id="2">
...
</F>
<F id="3">
...
</F>
<F id="4">
...
</F>
.
.
.
<G/>
<H/>
<I/>
</B>
<C/>
<D/>
<E/>
</A>
Many thanks in advance.
Comment