在我的输入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"/>有什么想法吗?
发布于 2014-02-11 18:02:28
我不完全确定你在问什么,但是:
<xsl:template match="text()[parent::par/@class='para']">这样,@class='figurecaption'所在的par元素就会被排除在字符串分析之外。
如果需要,您可以编写与插图标题的文本相匹配的第二个模板,并对其进行单独操作:
<xsl:template match="text()[parent::par/@class='figurecaption']">https://stackoverflow.com/questions/21698287
复制相似问题