Avoid link on the figure caption as well How

2019-08-01 23:51发布

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?

标签: xslt xslt-2.0
1条回答
冷血范
2楼-- · 2019-08-02 00:44

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']">
查看更多
登录 后发表回答