I'm having trouble with an XSLT transformation of XML fragments. The source XML looks like so:
<XXX>
<Name>Sample</Name>
<MMM>
<AAA ID="A"/>
<MMM>
<BBB ID="B"/>
<MMM>
<AA ID="C"/>
<BB ID="D"/>
</MMM>
</MMM>
</MMM>
</XXX>
But it needs to be transformed into:
<XXX>
<Name>Sample</Name>
<MMM>
<MMM>
<MMM>
<AAA ID="A"/>
<BBB ID="B"/>
</MMM>
<AA ID="C"/>
</MMM>
<BB ID="D"/>
</MMM>
</XXX>
The rule is simple, the MMM element can only have two child element nodes. If only one of those nodes happen to be another MMM, it needs to occupy the first position.
It is easy using code, but these XML fragments are values to XML columns in an SQL database, and I want to use SQL along with XSLT to update those values.
Any pointer or suggestions?
<XXX> <Name>Sample</Name> <MMM> <MMM> <MMM> <AA ID="C"/> <BB ID="D"/> </MMM> <BBB ID="B"/> </MMM> <AAA ID="A"/> </MMM> </XXX>- Adolfo PerezMMMnodes that have two non-emptyMMMnodes as children? - Marcus Rickert