Xml 仅当两个TEI属性值相等时显示
我有一个Xml 仅当两个TEI属性值相等时显示,xml,xslt,xslt-3.0,tei,Xml,Xslt,Xslt 3.0,Tei,我有一个TEI文件,有两个部分,一个用于转录,一个用于翻译。在我的转录部分,我有,我想显示翻译部分的后代或自我,前提是=/。 我做了一个。每个部分的内容都在一个中 TEI: <teiCorpus xmlns="http://www.tei-c.org/ns/1.0"> <text xml:id="KTU1"> <body> <div1 type="transcription"> <div2 type="tablet
TEI
文件,有两个部分,一个用于转录,一个用于翻译。在我的转录部分,我有
,我想显示翻译部分
的后代或自我,前提是
=/
。
我做了一个
。每个部分的内容都在一个
中
TEI
:
<teiCorpus xmlns="http://www.tei-c.org/ns/1.0">
<text xml:id="KTU1">
<body>
<div1 type="transcription">
<div2 type="tablet" xml:id="ktu1-3"> <!-- an example of a tablet -->
<head>Cycle of Baʿlu: KTU 1.3 recto</head>
<div3 type="col"> <!-- an example of a column's tablet -->
<div4 n="1" xml:id="ktu1-3_ii_l1_to_4a">
<head>Palace of ʿAnatu: combat readiness</head>
<lg>
<l n="0" xml:id="ktu1-3_ii_l0"><gap extent="unknown" reason="lost" unit="line"><desc>About 25 lines missing</desc></gap>
</l>
<l n="1" xml:id="ktu1-3_ii_l1">
<w type="unknown">n</w><gap extent="unknown" reason="lost" confidence="1" unit="chars" quantity="6"/>[xxxxxxxxx]<w type="unknown">š</w>[xxx]
</l>
<l n="2-3a" xml:id="ktu1-3_ii_l2-3a">
<w type="noun" lemmaRef="uga/noun.xml#kpr">kpr</w>
<g>.</g>
<w type="num">šbʿ</w>
<g>.</g>
<w type="noun" lemmaRef="uga/noun.xml#bnt">bnt</w>
<g>.</g>
<w type="noun" lemmaRef="uga/noun.xml#rḥ">rḥ</w>
<g>.</g>
<w type="noun" lemmaRef="uga/noun.xml#gmd">gdm</w>
<lb/><w type="coo">w</w><space/>
<w type="noun" lemmaRef="uga/noun.xml#anh">anhbm</w>
<g>.</g>
</l>
</lg>
<!-- other <lg><l>...</l></lg> -->
</div4>
<div4 n="2" type="part" xml:id="ktu1-3_ii_l4b_to_16">
<head>ʾAnatu is fighting in the valley</head>
<lg>
<l n="4b-5a" xml:id="ktu1-3_ii_l4b-5a" ana="#ktu1-3_ii_l4b-5a_int">
<w type="coo">w</w><space/>
<w type="verb" lemmaRef="../uga/verb.html#qry"><damage degree="medium" facs="definir"><supplied resp="KTU">t</supplied></damage>qry</w>
<g>.</g>
<w type="noun" lemmaRef="uga/noun.xml#ġlm" xml:id="ġlmm_4b-5a">ġlmm</w>
<lb/><w type="prep">b</w><space/>
<w type="noun" lemmaRef="uga/noun.xml#št">št</w>
<g>.</g>
<w type="noun" lemmaRef="uga/noun.xml#ġr">ġr</w>
<g>.</g>
</l>
</lg>
</div4>
<!-- other <div4><head/><lg><l>...</l></lg> -->
</div3>
</div2>
</div1>
<div1 type="translation">
<!-- here, translation of previous <div n="1"> -->
<div2 n="1" ana="#ktu1-3_ii_l1_to_4a" xml:id="trans-ktu1-3_ii_l1_to_4a">
<div3 n="0" ana="#ktu1-3_ii_l1">
<entry>
<interp xml:id="trans-VJ-ktu1-3_ii_l1">[Missing]</interp>
</entry>
</div3>
<div3 n="1" ana="#ktu1-3_ii_l2-3a">
<entry>
<interp xml:id="trans-VJ-ktu1-3_ii_l2-3a">[translation impossible </interp>
</entry>
</div3>
<div3 n="2-3a" ana="#ktu1-3_ii_l2-3a">
<entry>
<interp xml:id="trans-VJ-ktu1-3_ii_l2-3a">henna of seven tamarisks, scents of coriander and sea snail</interp>
</entry>
</div3>
<!-- other div3 with content = <lg><l></l></lg> -->
</div2>
<div2 n="2" ana="#ktu1-3_ii_l4b_to_16" xml:id="trans-ktu1-3_ii_l4b_to_16">
<div3 n="4b-5a" ana="#ktu1-3_ii_l4b-5a">
<entry>
<interp xml:id="trans-VJ-ktu1-3_ii_l4b-5a">and she met youths at the foot of the mountain</interp>
</entry>
</div3>
<!-- other div3 with content = <lg><l></l></lg> -->
</div2>
<!-- other div2 for each translation of <div n=" "> -->
</div1>
</body>
</text>
</teiCorpus>
由于TEI
在多个层次上都有点复杂,因此我还对TEI
和XSLT
进行了XLST整理:
因此,目前,翻译部分的预期结果是正确的:
<td>
<ul>
<li>[Missing]</li>
<li>[translation impossible]</li>
<li>henna of seven tamarisks, scents of coriander and sea snail</li>
</ul>
</td>
<td>
<ul>
<li>and she intercepts youths at the foot of the mountain</li>
</ul>
</td>
我试过:
<ul>
<li>
<xsl:for-each select="//key('div1', 'translation')/div2">
<xsl:if test="./substring(@ana, 2) = preceding::div4/@xml:id"/>
<xsl:value-of select="."/>
</xsl:for-each>
</li>
</ul>
-
但是结果并不好,因为它显示了翻译的每个
的所有
<td>
<ul>
<li>[Missing][translation impossible]henna of seven tamarisks, scents of coriander and sea snail and she met youths at the foot of the mountain
</li>
</ul>
</td>
- [失踪][翻译不可能]七棵柽柳的指甲花,芫荽和海螺的香味,她在山脚下遇到了年轻人
请道歉,用流利的英语解释所有步骤并不容易,但我希望你能理解我的意图
再次感谢您的建议。我想您确实有一个密钥设置,可以用来参考右侧部分的翻译:
<td>
<xsl:variable name="referenced-div1" select="key('div1', 'translation')"/>
<xsl:variable name="referenced-translation" select="key('div2-trans', '#' || @xml:id, $referenced-div1)"/>
<ul>
<xsl:for-each select="$referenced-translation/div3/entry/interp">
<li><xsl:value-of select="."/></li>
</xsl:for-each>
</ul>
</td>
很抱歉,您的帖子令人困惑。请清楚地显示输入XML、您应用的XSLT、与输入相对应的实际输出以及所需的输出。@Jim:对不起,由于代码有点长且复杂,我做了一个xsltfiddle。但现在我已经熟悉了这里的xsltfiddle内容。我希望现在好多了。谢谢。谢谢@Martin。但也许我做错了什么,因为它不起作用。因此,我还尝试将@xml:id
替换为@ana
(键('div2-trans',@ana,$referenced-div1)”/>
,因为我对'div2-trans'
的键用法是@ana
)但是…这里是更新的@Vanessa,我想我忽略了您用于键值的ana
属性值的前缀是一个哈希符号,因此在表达式中有必要使用该符号作为@xml:id
的前缀,XSLT/XPath 3中最简单的方法是使用'#|@xml:id
,请参见编辑后的答案。谢谢@Martin!很好用。我不知道连接两个字符串的新XPath 3.0运算符。您的帮助非常有用。非常感谢。
<td>
<ul>
<li>[Missing][translation impossible]henna of seven tamarisks, scents of coriander and sea snail and she met youths at the foot of the mountain
</li>
</ul>
</td>
<td>
<xsl:variable name="referenced-div1" select="key('div1', 'translation')"/>
<xsl:variable name="referenced-translation" select="key('div2-trans', '#' || @xml:id, $referenced-div1)"/>
<ul>
<xsl:for-each select="$referenced-translation/div3/entry/interp">
<li><xsl:value-of select="."/></li>
</xsl:for-each>
</ul>
</td>