Xml 在xslt中过滤后隐藏表行

Xml 在xslt中过滤后隐藏表行,xml,xslt,xsl-fo,Xml,Xslt,Xsl Fo,我想在xslt中完成过滤后隐藏表中的行结构,元素被隐藏,但行结构仍然显示 将“filter”属性添加到适用的元素中,并在样式表中引入一个与此filter属性的值匹配的变量 例如: <multi.document version="1" filterusing="k"> <table> <tbody> <row rowsep="0" filtering="k"> <entr

我想在xslt中完成过滤后隐藏表中的行结构,元素被隐藏,但行结构仍然显示

将“filter”属性添加到适用的元素中,并在样式表中引入一个与此filter属性的值匹配的变量

例如:

       <multi.document version="1" filterusing="k">
           <table>
     <tbody>
      <row rowsep="0" filtering="k">
       <entry align="left">
        <para.set legal="no">
         <para>
          ----
           </para> 
            </para.set>
            </entry>
             </row>
              </tbody>
              </table>

----
如果变量值“a”被传递到样式表,则包含“filter”属性的元素!='在处理过程中,将忽略“a”。如果元素不包含“filter”属性,则会正常处理(输出)

理想情况下,该变量将来自XML文档之外的源,但最好有一个根级别的可选属性,可以设置该属性,指定用于过滤的值


您的XSL-FO包含一个节,该节基于XML
行创建一个

要仅在输入XML行与筛选变量匹配时创建FO行,请执行以下操作:

<xsl: if test="@filtering = $filter">
    <fo:table-row>
        etc. 

下面是用于隐藏行结构的代码,它工作正常

<xsl:variable name="rowsep">
  <xsl:choose>
  <!-- If this is the last row, rowsep never applies. -->
    <xsl:when test="not(ancestor-or-self::row[1]/following-sibling::row or ancestor-or-self::thead/following-sibling::tbody or ancestor-or-self::tbody/preceding-sibling::tfoot) and not (ancestor-or-self::tbody/parent::tgroup/@sort='yes')">
      <xsl:value-of select="0"/>
    </xsl:when>
    <xsl:when test="ancestor::row/@filtering and ancestor::row/@filtering!=$filter">0</xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="inherited.table.attribute">
        <xsl:with-param name="entry" select="."/>
        <xsl:with-param name="colnum" select="$entry.colnum"/>
        <xsl:with-param name="attribute" select="'rowsep'"/>
      </xsl:call-template>
    </xsl:otherwise>
  </xsl:choose>
</xsl:variable>

0
: -->

0
0
<xsl:variable name="rowsep">
  <xsl:choose>
  <!-- If this is the last row, rowsep never applies. -->
    <xsl:when test="not(ancestor-or-self::row[1]/following-sibling::row or ancestor-or-self::thead/following-sibling::tbody or ancestor-or-self::tbody/preceding-sibling::tfoot) and not (ancestor-or-self::tbody/parent::tgroup/@sort='yes')">
      <xsl:value-of select="0"/>
    </xsl:when>
    <xsl:when test="ancestor::row/@filtering and ancestor::row/@filtering!=$filter">0</xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="inherited.table.attribute">
        <xsl:with-param name="entry" select="."/>
        <xsl:with-param name="colnum" select="$entry.colnum"/>
        <xsl:with-param name="attribute" select="'rowsep'"/>
      </xsl:call-template>
    </xsl:otherwise>
  </xsl:choose>
</xsl:variable>
<xsl:variable name="colsep">
  <xsl:choose>
  <!-- If this is the last column, colsep never applies. -->
    <xsl:when test="$following.spans = ''">0</xsl:when>
    <xsl:when test="ancestor::row/@filtering and ancestor::row/@filtering!=$filter">0</xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="inherited.table.attribute">
        <xsl:with-param name="entry" select="."/>
        <xsl:with-param name="colnum" select="$entry.colnum"/>
        <xsl:with-param name="attribute" select="'colsep'"/>
      </xsl:call-template>
    </xsl:otherwise>
  </xsl:choose>
</xsl:variable>