我想使用我的xsl文件在我的PDF报告中创建一个标题。如果源文件包含超链接,则应将其呈现为超链接,否则为纯文本。使用xlst将xml转换为xsl-fo时动态创建超级链接?
例如,我的XML看起来像:
<a href='http://google.com' target='_blank'>This is the heading </a>"
它应该显示的超链接(如果有),否则显示的标题为纯文本。 我该怎么做?
我不能够使用,否则标签下,下面的代码,请参见下面
<xsl:choose>
<xsl:when test="($RTL='true') or ($RTL='True')">
<fo:block wrap-option="wrap" hyphenate="true" text-align="right" font-weight="bold">
<xsl:value-of select="@friendlyname" />
</fo:block>
</xsl:when>
<xsl:otherwise>
<!--<fo:block wrap-option="wrap" hyphenate="true" font-weight="bold">-->
<xsl:template match="a">
<fo:block>
<xsl:choose>
<xsl:when test="@href">
<fo:basic-link>
<xsl:attribute name="external-destination">
<xsl:value-of select="@href"/>
</xsl:attribute>
<xsl:value-of select="@friendlyname" />
</fo:basic-link>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@friendlyname" />
</xsl:otherwise>
</xsl:choose>
</fo:block>
</xsl:template>
<!--<xsl:value-of select="@friendlyname" />-->
<!--</fo:block>-->
</xsl:otherwise>
</xsl:choose>
</xsl:if>
我如何使用它呢?
这是使用'xsl:template'元素的不正确方法。它不能在'否则'里面。所以,现在(即自更新了您的问题以来),您的问题与基本链接无关,但具有编写XSLT代码的基本规则。 –