有什么“喜欢” CSS内置到XSL-FO? [英] Is there something "like" CSS built into XSL-FO?

查看:187
本文介绍了有什么“喜欢” CSS内置到XSL-FO?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道XSLT本身有属性集,但这迫使我使用

I know that XSLT itself has attribute-sets, but that forces me to use

<xsl:element name="fo:something">

每次我想输出

<fo:something>

标记。 XSL-FO规范中是否有任何内容允许我为FO输出中的所有表指定一个默认属性集(边距,填充等)?

tag. Is there anything in the XSL-FO spec that would allow me to specify (let's say) a default set of attributes (margin, padding, etc.) for all Tables in the FO output?

基本上我在寻找CSS的功能,但是对于FO输出而不是HTML。

Essentially I'm looking for the functionality of CSS, but for FO output instead of HTML.

推荐答案

,您不需要使用xsl:element,如果将它放在XSLT命名空间中,use-attribute-sets属性可以出现在文字结果元素上,因此您可以使用类似:

No, you are not required to use xsl:element, the use-attribute-sets attribute can appear on literal result elements if you place it in the XSLT namespace, so you can use something like:

<fo:something xsl:use-attribute-sets="myAttributeSet">

如果你想要接近CSS的功能,你可以添加另一个XSLT转换的处理,添加您想要的属性。您可以先使用递归标识转换,然后添加与要更改的元素匹配的模板。

If you want to have something close to the CSS functionality then you can add another XSLT transformation at the end of your processing that adds the attributes that you want. You can start with a recursive identity transformation and then add templates matching on the elements you want to change, see a small example below

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:attribute-set name="commonAttributes">
    <xsl:attribute name="common">value</xsl:attribute>
  </xsl:attribute-set>
  <xsl:template match="node() | @*">
    <xsl:copy>
      <xsl:apply-templates select="node() | @*"/>
    </xsl:copy>
  </xsl:template>
  <xsl:template match="someElement">
    <xsl:copy use-attribute-sets="commonAttributes">
      <xsl:attribute name="someAttribute">someValue</xsl:attribute>
      <xsl:apply-templates select="node() | @*"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

这篇关于有什么“喜欢” CSS内置到XSL-FO?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆