首页 > 解决方案 > xsl:template - 如何从右到左呈现页面?

问题描述

我有xsl:template它当前正在从 渲染left to right,我希望从 渲染它right to left

<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    xmlns:report="http://caretalks.somecompanyname.com/IET/2007/12"
    xmlns:Parse="com.somecompanyname.caretalks.util.StringParserUtils"
    xmlns:Ext="com.somecompanyname.caretalks.util.XsltUtils"
    exclude-result-prefixes="fo">


    <xsl:template match="report:memberEngagementReport">
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
          <fo:layout-master-set>
            <fo:simple-page-master master-name="simpleA" page-height="11in"
                    page-width="8.5in" margin-top="0.5cm" margin-bottom="0.5cm"
                    margin-right="0.5cm" margin-left="0.5cm"
                    writing-mode="{$writingMode}">
                <fo:region-body margin-top="1cm" margin-bottom="2.6cm"
                        margin-right="1.5cm" margin-left="1.5cm"/>
                <fo:region-before extent="0.5cm"/>
                <fo:region-after extent="2.0cm"/>
            </fo:simple-page-master>
          </fo:layout-master-set>

    .
    .
    .
    .
    </xsl:template>
</xsl:stylesheet>

我在网上搜索了可能的解决方案,但找不到我需要的东西。

我该怎么做才能渲染它right to left

我也在寻找为双方(LTR / RTL)渲染它并维护一个原始XSL文件的方法。

标签: pdfxsl-foright-to-left

解决方案


writing-mode是继承的,所以设置它writing-mode="rl"fo:root应用于整个文档。请参阅https://www.w3.org/TR/xsl11/#writing-mode

你好像用的是FOP,所以如果你想让不同区域的内容有不同的写模式,你不能用from-page-master-region()从页面区域获取写模式。但是,由于您有一个用于书写模式的变量,您可以writing-mode在每个fo:flow或上设置fo:static-content


推荐阅读