Как убрать запятые вместе с некоторыми встроенными элементами?

Я работаю над удалением номеров страниц из терминов индекса - просто отображаю термины без номеров страниц.

Я изо всех сил пытаюсь найти шаблон подстановки, чтобы искать запятую, за которой следует тег ссылки.

Вот входной XML:

    <book>
    <index xml:id="index01"><title>Index</title>
    <indexdiv><title>A</title>
    <indexentry xml:id="ie001"><primaryie>abdomen, of neonates, <link role="page" linkend="pg68">68</link></primaryie></indexentry>
    <indexentry xml:id="ie002"><primaryie>abnormal amniotic fluid volume, <link role="page" linkend="pg56">56</link>, <link role="page" linkend="pg56">56</link><emphasis role="italic">t</emphasis></primaryie></indexentry>
    <indexentry xml:id="ie003"><primaryie>abruption placentae. <emphasis role="italic">See</emphasis> placental abruption</primaryie></indexentry>
    <indexentry xml:id="ie004"><primaryie>acceptable and repeatable, <link role="page" linkend="pg343">343</link>&#x2013;<link role="page" linkend="pg344">344</link>, <link role="page" linkend="pg343">343</link><emphasis role="italic">t</emphasis></primaryie>
    <secondaryie>pulmonary function testing, <link role="page" linkend="pg202">202</link>, <link role="page" linkend="pg340">340</link></secondaryie></indexentry>
    <indexentry xml:id="ie005"><primaryie>acinus, <link role="page" linkend="pg31">31</link></primaryie></indexentry>
    </indexdiv>
    </index>
    </book>

Мой код:

    <xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" expand-text="yes">

      <xsl:mode streamable="yes" use-accumulators="#all" on-no-match="shallow-copy"/>

      <xsl:output method="xml" encoding="utf-8" indent="yes"/>
      <xsl:variable name="document-uri" select="document-uri(.)"/>
      <xsl:variable name="isbn" select="substring-before((tokenize($document-uri,'/'))[last()],'.')"/>

    <xsl:template match="book">
    <book>
      <xsl:apply-templates select="index"/>
    </book>
    </xsl:template>

    <xsl:template match="index">
        <xsl:apply-templates select="indexdiv/indexentry"/>
    </xsl:template>

    <xsl:template match="indexentry">
      <xsl:apply-templates select="primaryie"/>
      <xsl:apply-templates select="secondaryie"/>
      <xsl:apply-templates select="tertiaryie"/>
    </xsl:template>

    <xsl:template match="primaryie">
        <col1><xsl:value-of select="text()"/></col1>
    </xsl:template>

    <xsl:template match="secondaryie">
      <col2><xsl:value-of select="text()"/></col2>
    </xsl:template>

    <xsl:template match="tertiaryie">
      <col3><xsl:value-of select="."/></col3>
    </xsl:template>

    <xsl:template match="link[@role='page']"/>
    <xsl:template match="emphasis[@role]"/>

    </xsl:stylesheet>

Я ожидаю следующий вывод, но я изо всех сил пытаюсь использовать сопоставление с образцом:

    <?xml version="1.0" encoding="utf-8"?>
    <book>
       <col1>abdomen, of neonates</col1>
       <col1>abnormal amniotic fluid volume</col1>
       <col1>abruption placentae.  placental abruption</col1>
       <col1>acceptable and repeatable</col1>
       <col2>pulmonary function testing</col2>
       <col1>acinus</col1>
    </book>

0 ответов

Другие вопросы по тегам