当重写attr集时,是否有办法从XSLT属性集中删除所有属性?

问题描述:

我正在使用一些第三方XSLT,它大量使用属性集来将XML转换为各种形式的XSL:FO。例如:当重写attr集时,是否有办法从XSLT属性集中删除所有属性?

notes.xsl:

<xsl:template match="note"> 
    <fo:block xsl:use-attribute-sets="noteAttrs"> 
     <!-- This is a pretty big template with lots of xsl:choose/xsl:if/etc. --> 
    </fo:block> 
<xsl:template> 

<xsl:attribute-set name="noteAttrs"> 
    <xsl:attribute name="margin-left">10px</xsl:attribute> 
    <xsl:attribute name="margin-right">8px</xsl:attribute> 
    <xsl:attribute name="margin-top">5px</xsl:attribute> 
    <xsl:attribute name="font-size">10pt</xsl:attribute> 
    <!-- several other attributes --> 
</xsl:attribute> 

的想法是,我导入此XSLT,重新定义属性设置为我认为合适的。如果我只需要对于给定的文件.fo不同的字体大小...

<xsl:import href="notes.xsl"/> 
<xsl:attribute-set name="noteAttrs"> 
    <xsl:attribute name="font-size">12pt</xsl:attribute> 
</xsl:attribute> 

的问题是,有时我需要平坦出删除属性(即,使得我从继承含有FO:块),或一个给定的fo文件会变得如此不同,以至于从新开始而不是将我的属性集与notes.xsl中的属性集合合起来将会更容易。在XSLT 2.0中有没有这样做的方法,无需重新生成整个模板以便在fo:block中指定不同的属性集?我想我希望能够做这样的事情:

<xsl:import href="notes.xsl"/> 
<xsl:attribute-set name="noteAttrs" merge_with_imported_attr_set="false"> 
    <xsl:attribute name="font-size">12pt</xsl:attribute> 
</xsl:attribute> 

我不能切换到XSLT 3.0处理器马上,但如果有在3.0新的东西,使这个,我很乐意了解它。

谢谢!

属性集不是非常广泛的使用,为了回答你的问题,我不得不看看规范来刷新我的记忆。我不认为有什么办法可以达到你想要的;您无法真正覆盖导入样式表中设置的属性,您只能对其进行补充。在精心设计的XML词汇表中,通常可以设置一个属性值,这相当于省略了属性,但如果情况并非如此,那么您就被卡住了。

+0

感谢您的信息! – user2292068