I need to transform large XML files that have a nested (hierarchical) structure of the form
Flat XML
Hierarchical XML (multiple blocks, so
Here is a generic solution as requested:
When applied on the provided simplified (and generic) XML document:
...
...
...
A
B
...
...
...
the wanted, correct result is produced:
...
...
A
...
...
...
...
B
...
...
Now, if we change the line:
to:
and apply the transformation to the Employee
XML document:
123 A Street
28
List of previous jobs in the US
3
01/10/2001
38
01/12/2004
6
01/06/2005
10
List of previous jobs in the UK
2
01/05/1999
25
01/07/2001
3
true
6
we again get the wanted, correct result:
123 A Street
28
List of previous jobs in the US
3
01/10/2001
38
true
6
123 A Street
28
List of previous jobs in the US
3
01/12/2004
6
true
6
123 A Street
28
List of previous jobs in the US
3
01/06/2005
10
true
6
123 A Street
28
List of previous jobs in the UK
2
01/05/1999
25
true
6
123 A Street
28
List of previous jobs in the UK
2
01/07/2001
3
true
6
Explanation: The processing is done in a named template (StructRepro
) and controlled by a single external parameter named pLeafNodes
, that must contain a nodeset of all nodes whose "upward structure" is to be reproduced in the result.