Sydney Office
SYDNEY
This transformation:
when applied on the provided source XML document:
Sydney Office
SYDNEY
Peak Night
PEANIG
30849.3
9
16.35
19
produces the wanted, correct result:
Sydney Office
SYDNEY
Peak Night
PEANIG
20050703
30849.3
9
20050710
16.35
19
when applied on the second provided XML document, requested in an Update by the OP:
Sydney Office
SYDNEY
Peak Night
PEANIG
30849.3
16.35
19
again the wanted, correct result (No
element is generated if the immediate sibling isn't a W_nnnnnnnn_Spots
) is produced:
Sydney Office
SYDNEY
Peak Night
PEANIG
20050703
30849.3
20050710
16.35
19
Do note:
The use of the identity rule to copy any node "as-is".
The overriding of the identity template only for W_nnnnnnnn_Dlr
elements.
The overriding of the identity template with an empty template matching W_nnnnnnnn_Spots
elements.
The use of the standard XPath functions: name(), starts-with() and substring-after()
The function ends-with() is only available in XPath 2.0 (XSLT 2.0) and isn't used in this XSLT 1.0 solution.