这个 XSLT 1.0 转换:
<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>
当应用于以下 XML 文档时:
<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>
应用于此 XML 文档时:
<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>
再次产生了想要的正确结果(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>