</xsl:copy>
</xsl:template>
+ <xsl:template match="rng:group" mode="flatten">
+ <xsl:choose>
+ <xsl:when test="ancestor::doc:attributes
+ and count(*) = count(rng:optional[rng:attribute])">
+ <xsl:apply-templates mode="flatten"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates mode="flatten"/>
+ </xsl:copy>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
<xsl:template match="doc:content-model//rng:choice/rng:choice
|doc:content-model//rng:zeroOrMore/rng:choice
|doc:content-model//rng:oneOrMore/rng:choice