条件格式XSL

当我遇到<sup>元素时,我试图使其上标。我正在遍历一个大文件,如果需要的话,我可以将其包括在内,基本上<xml><article><body><p><em></em><sup></sup></p></body></article></xml>

我收到:

  

XML解析器报告的错误:元素类型“ fo:inline”必须终止于     匹配的结束标签“ </fo:inline>

当尝试使用下面的符号上标时:

<xsl:for-each select="*">
    <fo:block>
        <xsl:if test="name() = 'sup'">
            <fo:inline vertical-align='super' baseline-shift='4pt'>
        </xsl:if>
        <xsl:apply-templates select="." mode="xhtml"/>
        <xsl:if test="name() = 'sup'">
            </fo:inline>
        </xsl:if>
    </fo:block>
</xsl:for-each>

我该如何更正此问题,以使vertical-align='super'仅适用于sup个元素;有没有更好的方法呢?我计划稍后再em执行相同的操作。

我当前使用但将所有内容都以纯文本形式显示的代码是:

<xsl:for-each select="*">
    <fo:block><xsl:apply-templates select="." mode="xhtml"/></fo:block>
</xsl:for-each>
hanjunwei88122188 回答:条件格式XSL

如果您要将<sup></sup>转换为<fo:inline vertical-align='super' baseline-shift='4pt'></fo:inline>,那么使用XSLT的通常方法是设置模板

<xsl:template match="sup">
  <fo:inline vertical-align='super' baseline-shift='4pt'>
    <xsl:apply-templates/>
  </fo:inline>
</xsl:template>

我不确定您是要一般还是针对特定模式执行此操作(在这种情况下,请在mode="mode-name"上添加xsl:template,在mode="#current"上添加xsl:apply-templates )。

本文链接:https://www.f2er.com/3142915.html

大家都在问