0
我有类似的问题:Using XSLT to create XSL-FO with nested bold/italic tags。我想要检测XML文本中的<italic>
和<bold>
标记,并将其标记为使用XSLT格式化。 我试过它像其他问题的解决方案,但它似乎不适合我。我错过了什么?使用xpath和/或xsl-fo格式化斜体/粗体标记
这是我的XML结构:
<bibliography>
<type1>
Some text and <italic>italic Text</italic> and <bold>bold text</bold>
</type1>
<type2>
Some text and <italic>italic Text</italic> and <bold>bold text</bold>
</type2>
</bibliography>
这XSL工作,但没有<italic>
或<bold>
标签:
<xsl:template match="/bibliography/*">
<p>
<div class="entry{@type}">
[<xsl:number count="*"/>]
<xsl:apply-templates/>
</div>
</p>
</xsl:template>
这是我试图用我的XML结构的解决方案:
<xsl:template match="/bibliography/*">
<p>
<div class="entry{@type}">
[<xsl:number count="*"/>]
<xsl:apply-templates/>
</div>
</p>
</xsl:template>
<xsl:template match="/">
<div class="entry{@type}">
<p>
<fo:root>
<fo:page-sequence>
<fo:flow>
<xsl:apply-templates select="bibliography"/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</p>
</div>
</xsl:template>
<xsl:template match="italic">
<fo:inline font-style="italic">
<xsl:apply-templates select="node()"/>
</fo:inline>
</xsl:template>
<xsl:template match="bold">
<fo:inline font-weight="bold">
<xsl:apply-templates select="node()"/>
</fo:inline>
</xsl:template>
我读过XSL-Fo仅适用于PDF而不适用于HTML。这是否意味着没有选项可以将fo对象导出为HTML?在没有XSL-FO的情况下,是否可以添加''和''? –
Peter
xsl-fo通常用于输出HTML。如果你想在浏览器中显示结果,只需修改它来输出HTML标签。我看到你已经为此提出了另一个问题,我用这个答案的一个变体来回答。我希望它有帮助。 –