避免在图标题上链接如何

时间:2014-02-11 09:47:48

标签: xslt xslt-2.0

在我输入的xml上,我在很多地方都有数字,图像及其交叉链接文字。当我尝试使用标记编写交叉链接时,它也会在标题文本上进行交叉链接。但是,除了标题文本之外,我需要在任何地方编码交叉链接。

<par class="para">In addition to the core publications, there is also a complementary set of ITIL publications providing guidance specific to industry sectors, organization types, operating models and technology architectures on `Figure 1.1`.</par>

        <par class="figurecaption">Figure 1.1  The ITIL service lifecycle</par>
        <par class="image">gr000001</par>

我的xslt代码

<xsl:template match="text()" exclude-result-prefixes="html">
<xsl:analyze-string select="." regex="(Chapter|Figure|Table|Appendix)\s(\d+|[A-Z])(\.)?(\d+)?|(www.[^ ]+)|(http://[^ ]+)|(Section|section)\s(\d)\.(\d+)(\.)?(\d+|\d)?(\.)?(\d)?" flags="x">
<xsl:matching-substring>        
<a><xsl:attribute name="href">

.....

它产生结果

<p>In addition to the core publications, there is also a complementary set of ITIL publications providing guidance specific to industry sectors, organization types, operating models and technology architectures on `<a href="chapter1.html#Fig1">Figure 1.1</a>`.</p>

    <p><a href="chapter1.html#Fig1">Figure 1.1</a>  The ITIL service lifecycle</p>
    <img src="gr000001"/>

但是,我需要

<p>In addition to the core publications, there is also a complementary set of ITIL publications providing guidance specific to industry sectors, organization types, operating models and technology architectures on `<a href="chapter1.html#Fig1">Figure 1.1</a>`.</p>

<p>`Figure 1.1`  The ITIL service lifecycle</p>
        <img src="gr000001"/>

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

我不完全确定你在问什么,但是怎么样:

<xsl:template match="text()[parent::par/@class='para']">

这样,par元素从字符串分析中排除@class='figurecaption'

如果需要,您可以编写第二个与图标字幕文本相匹配的模板并单独操作:

<xsl:template match="text()[parent::par/@class='figurecaption']">