使用XSL:关键字循环将文章XML转换为HTML



我正在尝试将XML文章转换为HTML,但是其他语言中的关键字并未显示。附加了XML文件和XSL文件。

XML 这是XML中的摘要。请注意,有两个标签抽象和反应,它们具有关键字

            <abstract>
            <title>RESUMEN</title>
            <p>
                <italic>En este artículo se presenta la importancia que le da Hannah Arendt al relato histórico y ficticio como vía para la reflexión ética y política. </italic>
            </p>
        </abstract>
        <trans-abstract xml:lang="en">
            <title>ABSTRACT</title>
            <p>
                <italic>This article presents the importance given by Hannah Arendt to historical and fictional stories as a way for ethical and political reflection.</italic>
            </p>
        </trans-abstract>
        <kwd-group xml:lang="es">
            <title>Palabras clave:</title>
            <kwd>Narración</kwd>
            <kwd>política</kwd>
            <kwd>acción</kwd>
            <kwd>identidad</kwd>
            <kwd>memoria</kwd>
            <kwd>juicio</kwd>
        </kwd-group>
        <kwd-group xml:lang="en">
            <title>Keywords:</title>
            <kwd>Narration</kwd>
            <kwd>politics</kwd>
            <kwd>action</kwd>
            <kwd>identity</kwd>
            <kwd>memory</kwd>
            <kwd>judgement</kwd>
        </kwd-group>

XSL 现在,这是XSL文件,它具有两个用于抽象的循环(语言原始(,另一个用于翻译的循环。抽象有效,但另一个不作用。也许是循环的条件。

<xsl:for-each select="abstract">
      <!-- title in left column, content (paras, secs) in right -->
      <div class="metadata two-column table">
        <div class="row">
          <div class="cell" style="text-align: right">
            <h4 class="callout-title">
              <xsl:apply-templates select="title/node()"/>
              <xsl:if test="not(normalize-space(string(title)))">
                <span class="generated">
                  <xsl:if test="self::trans-abstract">Translated </xsl:if>
                  <xsl:text>Abstract</xsl:text>
                </span>
              </xsl:if>
            </h4>
          </div>
          <div class="cell">
            <xsl:apply-templates select="*[not(self::title)]"/>
          </div>
        </div>
        <div class="row">
          <div class="cell" style="text-align: right">
            <h4 class="callout-title">
              <xsl:if test="not(normalize-space(string(attribute::xml:lang)))">
                <xsl:apply-templates select="../kwd-group[@xml:lang=/article/@xml:lang]/title/node()"/>
              </xsl:if>
            </h4>
          </div>
          <div class="cell">
            <h4 class="callout-title">
              <xsl:if test="not(normalize-space(string(attribute::xml:lang)))">
                <xsl:apply-templates select="../kwd-group[@xml:lang=/article/@xml:lang]/kwd/node()"/>
              </xsl:if>
            </h4>
          </div>
        </div>
      </div>
    </xsl:for-each>
    <!-- title in left column, content (paras, secs) in right -->
    <xsl:for-each select="trans-abstract ">
      <!-- title in left column, content (paras, secs) in right -->
      <div class="metadata two-column table">
        <div class="row">
          <div class="cell" style="text-align: right">
            <h4 class="callout-title">
              <xsl:apply-templates select="title/node()"/>
              <xsl:if test="not(normalize-space(string(title)))">
                <span class="generated">
                  <xsl:if test="self::trans-abstract">Translated </xsl:if>
                  <xsl:text>Abstract</xsl:text>
                </span>
              </xsl:if>
            </h4>
          </div>
          <div class="cell">
            <xsl:apply-templates select="*[not(self::title)]"/>
          </div>
        </div>
        <div class="row">
          <div class="cell" style="text-align: right">
            <h4 class="callout-title">
            <xsl:copy-of select="normalize-space(string(attribute::xml:lang))"/>
                <xsl:for-each select="/article/front/article-meta/kwd-group">
                  <xsl:copy-of select="."/>
                </xsl:for-each>
              <xsl:if test="normalize-space(string(attribute::xml:lang))">
                <xsl:apply-templates select="../kwd-group[@xml:lang=normalize-space(string(attribute::xml:lang))]/title/node()"/>
              </xsl:if>
            </h4>
          </div>
          <div class="cell">
            <h4 class="callout-title">
              <xsl:if test="normalize-space(string(attribute::xml:lang))">
                <xsl:apply-templates select="../kwd-group[@xml:lang=attribute::xml:lang]/kwd/node()"/>
              </xsl:if>
            </h4>
          </div>
        </div>
      </div>
    </xsl:for-each>

这是结果这里

<xsl:for-each select="trans-abstract ">内部的内部,如果要导航到同一语言的kwd-group,请使用../kwd-group[lang(current()/@xml:lang)]

最新更新