我希望在xslt中完成过滤后隐藏表中的行结构,元素被隐藏但行结构仍然显示。
将“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:variable name="filter" select="multi.document/@filterusing"></xsl:variable>
<xsl:template match="tbody/row/entry/para.set" mode="table">
<xsl:choose>
<xsl:when test="child::para/@change.bar='yes' or ancestor::table/@change.bar='yes'">
<xsl:choose>
<xsl:when test="ancestor::row/@filtering">
<xsl:choose>
<xsl:when test="$filter=ancestor::row/@filtering">
<xsl:choose>
<xsl:when test="parent::entry/@align='left' and string-length(parent::entry/preceding-sibling::entry/child::para.set/child::para)=0 and not(parent::entry/preceding-sibling::entry)">
<fo:block xsl:use-attribute-sets="table_cell_cb_atts">
<xsl:apply-templates select="para[@language=$active_language]"/>
</fo:block>
</xsl:when>
<xsl:when test="parent::entry/@align='left' and not(parent::entry/preceding-sibling::entry/child::para.set/child::para/child::node())=0">
<fo:block xsl:use-attribute-sets="table_cell_col2_cb_atts">
<xsl:apply-templates select="para[@language=$active_language]"/>
</fo:block>
</xsl:when>
<xsl:when test="parent::entry/@align='right'">
<fo:block xsl:use-attribute-sets="table_cell_right_cb_atts">
<xsl:apply-templates select="para[@language=$active_language]"/>
</fo:block>
</xsl:when>
<xsl:otherwise>
<fo:block xsl:use-attribute-sets="table_cell_center_cb_atts">
<xsl:apply-templates select="para[@language=$active_language]"/>
</fo:block>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="ancestor::row/@filtering">
<xsl:choose>
<xsl:when test="$filter=ancestor::row/@filtering">
<fo:block xsl:use-attribute-sets="table_cell_atts">
<xsl:apply-templates select="para[@language=$active_language]"/>
</fo:block>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<fo:block xsl:use-attribute-sets="table_cell_atts">
<xsl:apply-templates select="para[@language=$active_language]"/>
</fo:block>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
答案 0 :(得分:0)
您的XSL-FO包含一个基于XML <fo:table-row>
创建row
的部分。
仅当输入XML行与过滤器变量匹配时才创建FO行:
<xsl: if test="@filtering = $filter">
<fo:table-row>
etc.
答案 1 :(得分:0)
以下是用于隐藏行结构的代码,它工作正常
.ion-card{
background-color: #101218;
border: 1px solid #4A4A4A;
margin:20px auto;
border-radius: 10px !important;
}
.ion_input{
color:#f4f4f4;
opacity: 0.6;
}
.ion_icon{
color:#f4f4f4;
opacity: 0.6;
font-size: 5px;
}
.home_back{
background-color: #15161D;
}
.item-inner, ion-item {
border-bottom-color: transparent !important;
box-shadow: none !important;
}
:
- &GT;
<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>