避免在图标题上链接以及如何 [英] Avoid link on the figure caption as well How
问题描述
在我的输入 xml 中,我在许多地方都有数字、图像及其交叉链接文本.当我尝试使用标签对交叉链接进行编码时,它也会在标题文本上进行交叉链接.但是,除了标题文本之外,我需要在任何地方编写交叉链接.
On my input xml i have the figures, images and its cross-linking text in many places. When I try to code cross link using tag, it does cross link on the caption text also. But, I need to code cross link everywhere except on the caption text.
<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 代码去
My xslt code goes
<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"/>
有什么想法吗?
推荐答案
我不完全确定你在问什么,但如何:
I am not entirely sure what you are asking, but how about:
<xsl:template match="text()[parent::par/@class='para']">
这样,@class='figurecaption'
中的 par
元素被排除在字符串分析之外.
That way, par
elements where @class='figurecaption'
are excluded from the string analysis.
如果需要,您可以编写第二个模板来匹配图形标题的文本并单独操作:
If needed, you can then write a second template that matches the text of figure captions and manipulate it separately:
<xsl:template match="text()[parent::par/@class='figurecaption']">
这篇关于避免在图标题上链接以及如何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!