xsl-fo 中的样式
Styling in xsl-fo
我无法理解 xsl-fo 中的样式。情况看起来像这样,我有一个 table,我想为这个 table 设置标签样式(对于每一行,它的第一个条目)。但只有一个 table。最好的方法是什么?
<table frame="none" outputclass="prefaceTable">
<tgroup cols="2">
<colspec colname="COLSPEC0" colwidth="0.2*" />
<colspec colname="COLSPEC1" colwidth="1.0*"/>
<tbody>
<row>
<entry align="right">Copyright</entry>
<entry ><p conref="copyright.dita#copyright/statement"></p>
</entry>
</row>
<row>
<entry align="right">Intended Purpose</entry>
<entry ><p conref="intendedpurpose.dita#intendedpurpose/statement" ></p></entry>
</row>
<row>
<entry align="right">Conventions Used</entry>
<entry><p conref="ConventionsUsed.dita#ConventionsUsed/statement"></p></entry>
</row>
</tbody>
</tgroup>
</table>
解决后编辑:
并且必须在 xsl-fo 中设置样式。基本上在@Radu 和@Kevin 的帮助下,我设法做到了这一点,但我不得不对其进行更多更改,因为我们有 DITA 2.0.1,它也发生了很大变化。但在大多数情况下,@Radu(将跟随兄弟更改为先前兄弟)和@Kevin(当然将 td 更改为条目)给出的解决方案应该有效。在我的情况下它没有,因为据我所见,我们有插件检查它是否是最后一个单元格和其他类似的东西,所以覆盖单元格并不那么容易。
您或许可以在 table 上设置一个具有特定自定义值的 @outputclass 属性。然后,您可以从 XSLT 代码中匹配条目,例如:
<xsl:template match="*[contains(@class, ' topic/table ')][@outputclass='specialFirstCell']/*/*[contains(@class, ' topic/tbody ')]/*[contains(@class, ' topic/row ')]/*[contains(@class, ' topic/entry ')][not(following-sibling::*[contains(@class, ' topic/entry ')])]">
<fo:table-cell xsl:use-attribute-sets="tbody.row.entry">
<xsl:attribute name="color">red</xsl:attribute>
<xsl:call-template name="commonattributes"/>
<xsl:call-template name="applySpansAttrs"/>
<xsl:call-template name="applyAlignAttrs"/>
<xsl:call-template name="generateTableEntryBorder"/>
<fo:block xsl:use-attribute-sets="tbody.row.entry__content">
<xsl:call-template name="processEntryContent"/>
</fo:block>
</fo:table-cell>
</xsl:template>
不清楚你在做什么。如果您发布一些清晰的 XML 和 XSL 来使用,那就更好了。假设您正在使用 table、tr 和 td 等简单标签。
您的特价table标有@class='special' ...
在你对细胞后代的匹配中(假设它是 td),你会写:
<xsl:template match="td[ancestor::table[@class='special']]">
<xsl:choose>
<xsl:when test="count(preceding-sibling::td) = 0">
<!-- your special cell -->
</xsl:when>
<xsl:otherwise>
<!-- all other cells in the special table-->
</xsl:otherwise>
</xsl:choose>
</xsl:template>
我无法理解 xsl-fo 中的样式。情况看起来像这样,我有一个 table,我想为这个 table 设置标签样式(对于每一行,它的第一个条目)。但只有一个 table。最好的方法是什么?
<table frame="none" outputclass="prefaceTable">
<tgroup cols="2">
<colspec colname="COLSPEC0" colwidth="0.2*" />
<colspec colname="COLSPEC1" colwidth="1.0*"/>
<tbody>
<row>
<entry align="right">Copyright</entry>
<entry ><p conref="copyright.dita#copyright/statement"></p>
</entry>
</row>
<row>
<entry align="right">Intended Purpose</entry>
<entry ><p conref="intendedpurpose.dita#intendedpurpose/statement" ></p></entry>
</row>
<row>
<entry align="right">Conventions Used</entry>
<entry><p conref="ConventionsUsed.dita#ConventionsUsed/statement"></p></entry>
</row>
</tbody>
</tgroup>
</table>
解决后编辑:
并且必须在 xsl-fo 中设置样式。基本上在@Radu 和@Kevin 的帮助下,我设法做到了这一点,但我不得不对其进行更多更改,因为我们有 DITA 2.0.1,它也发生了很大变化。但在大多数情况下,@Radu(将跟随兄弟更改为先前兄弟)和@Kevin(当然将 td 更改为条目)给出的解决方案应该有效。在我的情况下它没有,因为据我所见,我们有插件检查它是否是最后一个单元格和其他类似的东西,所以覆盖单元格并不那么容易。
您或许可以在 table 上设置一个具有特定自定义值的 @outputclass 属性。然后,您可以从 XSLT 代码中匹配条目,例如:
<xsl:template match="*[contains(@class, ' topic/table ')][@outputclass='specialFirstCell']/*/*[contains(@class, ' topic/tbody ')]/*[contains(@class, ' topic/row ')]/*[contains(@class, ' topic/entry ')][not(following-sibling::*[contains(@class, ' topic/entry ')])]">
<fo:table-cell xsl:use-attribute-sets="tbody.row.entry">
<xsl:attribute name="color">red</xsl:attribute>
<xsl:call-template name="commonattributes"/>
<xsl:call-template name="applySpansAttrs"/>
<xsl:call-template name="applyAlignAttrs"/>
<xsl:call-template name="generateTableEntryBorder"/>
<fo:block xsl:use-attribute-sets="tbody.row.entry__content">
<xsl:call-template name="processEntryContent"/>
</fo:block>
</fo:table-cell>
</xsl:template>
不清楚你在做什么。如果您发布一些清晰的 XML 和 XSL 来使用,那就更好了。假设您正在使用 table、tr 和 td 等简单标签。
您的特价table标有@class='special' ...
在你对细胞后代的匹配中(假设它是 td),你会写:
<xsl:template match="td[ancestor::table[@class='special']]">
<xsl:choose>
<xsl:when test="count(preceding-sibling::td) = 0">
<!-- your special cell -->
</xsl:when>
<xsl:otherwise>
<!-- all other cells in the special table-->
</xsl:otherwise>
</xsl:choose>
</xsl:template>