Я пытаюсь добавить якоря в мой вывод html.HTML создается с использованием xsl 2.0 для преобразования XML в HTML.Мне нужно иметь возможность передать список регулярных выражений в мою таблицу стилей и сделать каждый соответствующий экземпляр списка регулярных выражений в якоре.У меня есть код, который работает для одного регулярного выражения, но когда я запускаю список регулярных выражений через, я получаю кратные одного и того же абзаца.Я ни в коем случае не эксперт XSL 2.0.Я не уверен, что это можно сделать таким образом.Я тоже могу использовать c #, если это проще.если кто-то думает, что это будет лучшим решением, хотя я не уверен, что это так.
Код, который работает для одного регулярного выражения:
<xsl:template match="text()" mode="content">
<xsl:variable name="text">
<xsl:value-of select="."></xsl:value-of>
</xsl:variable>
<!--
IndexTerms is a parameter passed into the sheet it is a list of regex expressions seperated by semi colons
-->
<xsl:for-each select="tokenize($IndexTerms, ';')">
<xsl:call-template name="IndexTerm">
<xsl:with-param name="matchedRegex">
<xsl:text>(.*)(</xsl:text>
<xsl:value-of select="."></xsl:value-of>
<xsl:text>)(.*)</xsl:text>
</xsl:with-param>
<xsl:with-param name="text">
<xsl:value-of select="$text"></xsl:value-of>
</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="IndexTerm">
<xsl:param name="matchedRegex">
<xsl:text>asdf</xsl:text>
</xsl:param>
<xsl:param name="text"></xsl:param>
<xsl:analyze-string select="$text" regex="{$matchedRegex}" flags="m">
<xsl:matching-substring>
<xsl:call-template name="IndexTerm">
<xsl:with-param name="text">
<xsl:value-of select="regex-group(1)"></xsl:value-of>
</xsl:with-param>
<xsl:with-param name="matchedRegex">
<xsl:value-of select="$matchedRegex"></xsl:value-of>
</xsl:with-param>
</xsl:call-template>
<xsl:element name="a">
<xsl:attribute name="class">
<xsl:text>IndexAnchor</xsl:text>
</xsl:attribute>
<xsl:value-of select="regex-group(2)"></xsl:value-of>
</xsl:element>
<xsl:value-of select="regex-group(3)"></xsl:value-of>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."></xsl:value-of>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>
Пример ввода:
<body>
<sec sec-type="intro">
<title>INTRODUCTION</title>
<p>Digital Television is the most advanced version of Television
technology improved in the last century. Digital TV provides
customers more choices and interactivity. New technology called
Internet Protocol-based Television (IPTV) uses digital TV technology
and transmits it over IP based networks (Driscol, 2008),
(<xref ref-type="bibr" rid="r15">Moawad, 2008</xref>). IPTV is a
technique that transmits TV and video content over a network that
uses the IP networking protocol. With increasing the number of
users, performance becomes more important in order to provide
interest in video content applications and relative services. The
requirement for new video applications on traditional broadcast
networks (cable, terrestrial transmitters, and satellite) opens a
new perspective for the developed use of IP networks to satisfy the
new service demands (Driscol,
2008</p>
<sec>
<title>More Introducing</title>
<p>Internet Protocol Television, IPTV, Telco TV, or broadband TV is
delivering high quality broadcast television and/or on-demand video
and audio content over a broadband network. On the other hand, IPTV
is a mechanism applied to deliver old TV channels, movies, and
video-on-demand contents over a private network. The official
definition approved by the International Telecommunication Union
focus group on IPTV (ITU-T FG IPTV) is as: “IPTV is
defined as multimedia services such as
television/video/audio/text/graphics /data delivered over IP based
networks managed to provide the required level of quality of service
and experience, security, interactivity and reliability”
(Driscol, 2008,
pp.2).</p>
</sec>
</sec>
Пример вывода с использованием входного выражения Regex «Цифровое телевидение? Интернет» будет:
<body>
<h1>INTRODUCTION</h1>
<p><a class="IndexAnchor">Digital Television</a> is the most advanced version of Television
technology improved in the last century. Digital TV provides
customers more choices and interactivity. New technology called
<a class="IndexAnchor">Internet</a> Protocol-based Television (IPTV) uses digital TV technology
and transmits it over IP based networks (Driscol, 2008),
(Moawad, 2008). IPTV is a
technique that transmits TV and video content over a network that
uses the IP networking protocol. With increasing the number of
users, performance becomes more important in order to provide
interest in video content applications and relative services. The
requirement for new video applications on traditional broadcast
networks (cable, terrestrial transmitters, and satellite) opens a
new perspective for the developed use of IP networks to satisfy the
new service demands (Driscol,
2008</p>
<h2>More Introducing</h2>
<p><a class="IndexAnchor">Internet</a> Protocol Television, IPTV, Telco TV, or broadband TV is
delivering high quality broadcast television and/or on-demand video
and audio content over a broadband network. On the other hand, IPTV
is a mechanism applied to deliver old TV channels, movies, and
video-on-demand contents over a private network. The official
definition approved by the International Telecommunication Union
focus group on IPTV (ITU-T FG IPTV) is as: “IPTV is
defined as multimedia services such as
television/video/audio/text/graphics /data delivered over IP based
networks managed to provide the required level of quality of service
and experience, security, interactivity and reliability”
(Driscol, 2008,
pp.2).</p>