i need to remove xmi node if there is only 1 child. If i remove xmi node i need to copy attributes to new root node.
<xmi:XMI attribute="2" xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:a="A">
<namespace:node attribute2="att">
...
</namespace:node>
</xmi:XMI>
i need to get
<namespace:node attribute2="att" attribute="2" xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:a="A">
...
</namespace:node>
but if there is
<xmi:XMI attribute="2" xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:a="A">
<namespace:node attribute2="att">
...
</namespace:node>
<otherNode/>
</xmi:XMI>
no changes must be done.
Any help appreciated.
This XSLT 1.0 transformation:
when applied on the following XML document :
produces the wanted, correct result (no changes):
When applied on this XML document:
again the wanted, correct result is produced (the
xmi:XMIelement is “deleted” and its attributes are copied to its only child):