Hi,
I'm struggling to transform XML that looks like this:
<group name="Languages" displayName="Languages" order="4">
<field name="ppl_language" displayName="Language"> Spanish </field>
<field name="ppl_language" displayName="Language"> Portuguese </field>
<field name="ppl_language_native" displayName="Native?"> Yes </field>
<field name="ppl_language_native" displayName="Native?"> No </field>
<field name="ppl_language_speak" displayName="Spoken"> Fluent </field>
<field name="ppl_language_speak" displayName="Spoken"> Functional
</field>
<field name="ppl_language_write" displayName="Written"> Fluent </field>
<field name="ppl_language_write" displayName="Written"> Survival
</field>
</group>
What I need is output that looks like this:
Language: Spanish
Native?: Yes
Spoken: Fluent
Written: Fluent
Language: Portuguese
Native?: No
Spoken: Functional
Written: Survival
That is, the source document contains <field/> elements that are
returned grouped by their @name attribute values. The <field/> elements
are always returned in the order stated above, ppl_language,
ppl_language_native, ppl_language_speak, and ppl_language_write. There
can be an arbitrary number of language entries in the list, but it is
guaranteed that for every entry, all four <field/> elements will exist.
I am having trouble devising a strategy/writing a match pattern to group
the elements correctly. Can anyone make a suggestion? Obviously, the
problem is that there is only one <group/> element that is the parent
for all <field/> elements, no matter how many <field/> elements there
are. I'm using XSLT/XPath 2.0.
Best regards,
--Bill