【问题标题】:Remove specific regions from fo file in xsl-fo从 xsl-fo 中的 fo 文件中删除特定区域
【发布时间】:2020-07-07 05:50:29
【问题描述】:

我有一个定义如下的 xsl-fo 文件,

<?xml version="1.0" encoding="utf-8" ?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <fo:layout-master-set>
    <fo:simple-page-master master-name="master">
      <fo:region-body margin-bottom="0.5in" margin-top="0.9in" margin-left="35pt"/>
      <fo:region-before region-name="xsl-region-before" extent="0.9in"/>
      <fo:region-after region-name="xsl-region-after" extent="0.5in"/>
    </fo:simple-page-master>
  </fo:layout-master-set>
  <fo:page-sequence master-reference="master">
    
    <fo:static-content flow-name="xsl-region-before">
    Some not needed things will be here
    </fo:static-content>

    <fo:static-content flow-name="xsl-region-after">
    
    Some not needed things will be here
    
    </fo:static-content>

    <fo:flow flow-name="xsl-region-body">
      <fo:block font-size="10pt" xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <fo:table table-layout="fixed" space-after="0pt" border-collapse="separate" border-separation="0pt">
// This is the content that I need
  </fo:table>
</fo:block>
      <fo:block id="end"/>
    </fo:flow>
  </fo:page-sequence>
</fo:root>

有什么方法可以删除此 fo 中定义的一些我不需要处理的区域?我想做的是从 this 中完全删除 &lt;fo:static-content flow-name="xsl-region-after"&gt;&lt;fo:static-content flow-name="xsl-region-before"&gt; 。我怎样才能做到这一点 。非常感谢一些帮助

【问题讨论】:

标签: c# .net xsl-fo region


【解决方案1】:

假设您有一个可用的 XSLT 处理器,您可以使用一个样式表,它是一个身份模板加上一个更高优先级的模板来删除您不想要的元素:

<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="2.0"
    xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:template match="fo:static-content" />
 
<!-- Identity template. -->
<xsl:template match="@* | node()" mode="#all">
  <xsl:copy>
    <xsl:apply-templates select="@* | node()" mode="#current"/>
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-23
    • 2021-04-24
    • 2013-04-06
    • 1970-01-01
    • 2015-12-22
    • 1970-01-01
    • 1970-01-01
    • 2015-10-19
    相关资源
    最近更新 更多