Templates 使用某种选择器或变量将重复模板合并到单个模板中
如何将四个几乎相同的模板转换为一个模板?我希望能够有一个变量或至少一个可以指定父节点组的位置Templates 使用某种选择器或变量将重复模板合并到单个模板中,templates,xslt,Templates,Xslt,如何将四个几乎相同的模板转换为一个模板?我希望能够有一个变量或至少一个可以指定父节点组的位置 <!-- identity transform --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ViewSuperbillProcedureScrubFullInsurance/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillScrubFullInsurance/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillProcedureScrub/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillScrub/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
我试着做一些类似的事情
<xsl:template match="ViewSuperbillProcedureScrubFullInsurance|ViewSuperbillScrubFullInsurance|ViewSuperbillProcedureScrub|ViewSuperbillScrub/column/@width[not(../@AutoWidth)]">
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ViewSuperbillProcedureScrubFullInsurance/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillScrubFullInsurance/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillProcedureScrub/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillScrub/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
或
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ViewSuperbillProcedureScrubFullInsurance/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillScrubFullInsurance/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillProcedureScrub/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillScrub/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
或
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ViewSuperbillProcedureScrubFullInsurance/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillScrubFullInsurance/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillProcedureScrub/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillScrub/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
ViewSuperbillProcedureScrubFullInsurance | ViewSuperbillScrubFullInsurance | ViewSuperbillProcedureScrub | ViewSuperbillScrub
但什么都不管用
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ViewSuperbillProcedureScrubFullInsurance/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillScrubFullInsurance/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillProcedureScrub/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillScrub/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
以下是完整的xsl:
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ViewSuperbillProcedureScrubFullInsurance/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillScrubFullInsurance/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillProcedureScrub/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillScrub/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
假的
假的
假的
假的
您可以执行以下操作:
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ViewSuperbillProcedureScrubFullInsurance/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillScrubFullInsurance/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillProcedureScrub/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillScrub/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
应该以相同的方式处理而不是
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ViewSuperbillProcedureScrubFullInsurance/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillScrubFullInsurance/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillProcedureScrub/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
<xsl:template match="ViewSuperbillScrub/column/@width[not(../@AutoWidth)]">
<xsl:copy/>
<xsl:attribute name="AutoWidth">false</xsl:attribute>
</xsl:template>
</xsl:stylesheet>