简体   繁体   中英

Using XSLT to create XSL-FO with inline tag for every text

Based on the solution provided in this answer

I'd like to convert this HTML

<doc>
  <par>
    <point>
      <text><bold>bolded text</bold> and <italic>italic</italic></text>
    </point>
  </par>
</doc>

and obtain :

<fo:block>
    <fo:inline font-weight="bold">bolded text</fo:inline>
    <fo:inline> and </fo:inline>
    <fo:inline font-style="italic">italic</fo:inline>
</fo:block>

Note the difference with the solution provided in the link, i'd like to have every text in an fo:inline tag. In this example the string " and " is placed in an inline tag instead of the parent block tag.

How can i obtain this, please ?

Thank you for your help.

Gpo23

One option is to add a template specifically matching text() that is a direct child of text .

<xsl:template match="text/text()">
    <fo:inline>
        <xsl:value-of select="."/>
    </fo:inline>
</xsl:template>

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