- Need to remove xmi node if there are just 1 child
- <xmi:XMI attribute="2" xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:a="A">
- <namespace:node attribute2="att">
- ...
- </namespace:node>
- </xmi:XMI>
- <namespace:node attribute2="att" attribute="2" xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:a="A">
- ...
- </namespace:node>
- <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>
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:xmi="http://www.omg.org/spec/XMI/20110701">
- <xsl:output omit-xml-declaration="yes" indent="yes"/>
- <xsl:strip-space elements="*"/>
- <xsl:template match="node()|@*">
- <xsl:copy>
- <xsl:apply-templates select="node()|@*"/>
- </xsl:copy>
- </xsl:template>
- <xsl:template match="xmi:XMI[not(*[2])]">
- <xsl:apply-templates/>
- </xsl:template>
- <xsl:template match="xmi:XMI[not(*[2])]/*">
- <xsl:copy>
- <xsl:apply-templates select="node()|@* | ../@*"/>
- </xsl:copy>
- </xsl:template>
- </xsl:stylesheet>
- <xmi:XMI attribute="2"
- xmlns:xmi="http://www.omg.org/spec/XMI/20110701"
- xmlns:a="A" >
- <namespace:node attribute2="att" xmlns:namespace="some:namespace">
- ...
- </namespace:node>
- <otherNode/>
- </xmi:XMI>
- <xmi:XMI xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:a="A" attribute="2">
- <namespace:node xmlns:namespace="some:namespace" attribute2="att">
- ...
- </namespace:node>
- <otherNode/>
- </xmi:XMI>
- <xmi:XMI attribute="2"
- xmlns:xmi="http://www.omg.org/spec/XMI/20110701"
- xmlns:a="A" >
- <namespace:node attribute2="att" xmlns:namespace="some:namespace">
- ...
- </namespace:node>
- </xmi:XMI>
- <namespace:node xmlns:namespace="some:namespace"
- xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:a="A"
- attribute="2" attribute2="att">
- ...
- </namespace:node>
- <xsl:stylesheet
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- version="2.0"
- xmlns:xmi="http://www.omg.org/spec/XMI/20110701">
- <xsl:template match="@* | node()">
- <xsl:copy>
- <xsl:apply-templates select="@* , node()"/>
- </xsl:copy>
- </xsl:template>
- <xsl:template match="xmi:XMI[not(*[2])">
- <xsl:apply-templates/>
- </xsl:template>
- <xsl:template match="xmi:XMI[not(*[2])]/*">
- <xsl:copy>
- <xsl:apply-templates select="../@*, @*, node()"/>
- </xsl:copy>
- </xsl:template>
- </xsl:stylesheet>