我正在尝试将文章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>
这是结果 here
答案 0 :(得分:0)
在<xsl:for-each select="trans-abstract ">
内,如果您要导航到同一语言的kwd-group
,请使用../kwd-group[lang(current()/@xml:lang)]
。