简体   繁体   中英

Creating Change Bars Using XSL-FO

I have a document and I need to track changes using revision bars (black bars in the margin to indicate where changes have taken place).

The changed text is done using <span class="changeText"> .

Example code, below:

<p>This is the original text. This is the original text. This is the original text. This
is the original text. This is the original text. <span class="changeText">This text has
changed. This text has changed. This text has changed.</span> This is the original text.
</p>

在此处输入图片说明

I can get reasonably close by using

fo:block background-color="lightyellow" border-end-color="black"
border-start-style="solid" border-start-width="4pt" padding-start="25pt"

Of course, that treats the section as a block. I need to make it work inline... but have not been able to figure out the right code to provide this type of behavior having the text flow inline.

Any thoughts our input would be appreciated.

Thanks!

The revision bar can be realized using fo:change-bar and fo:change-bar-end in XSL-FO.

6.13.2 fo:change-bar-begin

https://www.w3.org/TR/xsl11/#fo_change-bar-begin

6.13.3 fo:change-bar-end

https://www.w3.org/TR/xsl11/#fo_change-bar-end

So it is needed to generate fo:change-bar-begin , fo:inline and fo:change-bar-end from <span class="changeText"> element at once such like following template:

<xsl:template match="span[string(@class) eq 'changeText']">
    <xsl:variable name="id" as="xs:string" select="generate-id(.)"/>
    <fo:change-bar-begin change-bar-class="{$id}" change-bar-color="black" change-bar-style="solid"/>
    <fo:inline background-color="yellow">
        <xsl:apply-templates/>
    </fo:inline>
    <fo:change-bar-end change-bar-class="{$id}"/>
</xsl:template>

The sample result:

在此处输入图片说明

This is generated by AH Formatter. Unfortunately FOP does not implement fo:change-bar-begin and fo:change-bar-end at this moment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM