I want to use XSLT to modify :
<Office Code="1" OtherAttribute="5">
<Customer CustomerId="0010" CodeModifier="A"/>
<Customer CustomerId="0011" CodeModifier="B"/>
<Customer CustomerId="0012" CodeModifier="B"/>
</Office>
<Office Code="2" OtherAttribute="6">
<Customer CustomerId="2010" CodeModifier="A"/>
<Customer CustomerId="0011" CodeModifier="C"/>
</Office>
into :
<Office Code="1A" OtherAttribute="5">
<Customer CustomerId="0010"/>
</Office>
<Office Code="1B" OtherAttribute="5">
<Customer CustomerId="0011"/>
<Customer CustomerId="0012"/>
</Office>
<Office Code="2A" OtherAttribute="6">
<Customer CustomerId="2010"/>
</Office>
<Office Code="2C" OtherAttribute="6">
<Customer CustomerId="0011"/>
</Office>
My goals :
- group every Customer entity with the same CodeModifier into Office entities. If there are some multiple CodeModifier, I will add Office entity. The Code attribute into Office will be modified (concatenation of CodeModifier of Client into the Office)
- (facultative but trivial I think) suppress the CodeModifier attribute and keep all other attribute
Does someone know how to do that ?
Here’s another approach, using matching templates only.
Tested as XSLT 1.0 under MSXSL 4.0
Outputs to: