Avoid link on the figure caption as well How

二次信任 提交于 2019-12-11 06:56:49

问题


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>

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">

.....

it produces the result

<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"/>

But, I need

<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"/>

Any idea?


回答1:


I am not entirely sure what you are asking, but how about:

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

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']">


来源:https://stackoverflow.com/questions/21698287/avoid-link-on-the-figure-caption-as-well-how

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!