1

我必须处理以下 XML 结构:

<p>[1] Intencio <emph rend="italic">nostra</emph>
  <anchor xml:id="AJH-L.1.1"/>de<anchor xml:id="AJH-L.1.2"/> some more like this..
</p>
<app from="#AJH-L.1.1" to="#AJH-L.1.2">
  <rdg wit="#V">in</rdg>
</app>

变成类似的东西:

<div>[1] Intencio <span class='italic'>nostra</span>
  de<a href='AJH-L.1.1'>1</a> and so on..
</div>
<div class='appEntry'>
  <span class='rdg'>in</span>
</div>

而 1 是上标。

我在构建实际设备时没有问题,但在构建脚注时,因为有关相关锚的信息来自外部设备元素。

除此之外,我不得不提一下,可以同时从 anchor-1 到 anchor-4 有一个额外的 app-Element。

我在这里看到了一个关于如何在这些伪重叠元素之间选择文本的问题,它对我帮助很大。但我找不到这个问题的任何解决方案。

在 TEI 中必须有这样一个标准方法的解决方案,但我找不到它,如果有人有任何建议,我会很高兴。

非常感谢提前,蒂莫

4

1 回答 1

0

所以这里有一个更复杂的 XML 示例,其中也包括重叠问题。

<div type='subdivision'>
  <p>
    ....
     <anchor xml:id="AJH-L.2.63"/>intellectus cum re que sentitur <anchor
     xml:id="AJH-L.2.64"/>in<anchor xml:id="AJH-L.2.65"/> apprehensione<anchor
     xml:id="AJH-L.2.66"/>
    ....
  </p>
  ....
  <app from="#AJH-L.2.64" to="#AJH-L.2.65">
    <rdg wit="#H #M #N #P #R #V">-</rdg>
  </app>
  <app from="#AJH-L.2.63" to="#AJH-L.2.66">
    <rdg wit="#M">- <emph rend="italic">hom.</emph></rdg>
  </app>
  ....
</div>

到目前为止我的 XSLT 模板:

    <xsl:template match="TEI:anchor">
      <xsl:variable select="@xml:id" name="anchorId"/>
      <xsl:for-each select="ancestor::TEI:p/TEI:app[@to=concat('#',$anchorId)]">
        <a class="rs" name="rs_{count(preceding::TEI:app)+1}"
          href="#app_{count(preceding::TEI:app)+1}">
          <xsl:value-of select="count(preceding::TEI:app)+1"/>
        </a>
      </xsl:for-each>
    </xsl:template>

    <xsl:template match="TEI:app">
    <xsl:variable select="substring(@from,2)" name="from"/>
    <xsl:variable select="substring(@to,2)" name="to"/>
    <table class="appEntry">
      <tr rowspan="{count(TEI:rdg)+1}">
        <td>
          <a name="app_{position()}" href="#rs_{position()}">
            <xsl:value-of select="position()"/>
          </a>
        </td>
        <td>
        <!-- the referenced text from between the anchors -->
           <xsl:value-of select="//TEI:div[current()]//text()[preceding::TEI:anchor[@xml:id=$from] and following::TEI:anchor[@xml:id=$to]]"/>
          <xsl:for-each select="TEI:rdg">
            <tr>
              <td>
                <!-- all readings -->
                <xsl:value-of select="."/>
              </td>
            </tr>
          </xsl:for-each>
        </td>
      </tr>
    </table>
  </xsl:template>

结果输出应如下所示:

<div class="maintext">
  ....
  intellectus cum re que sentitur in <a href="#app_32" name="rs_32" class="rs">32</a>
  apprehensione <a href="#app_33" name="rs_33" class="rs">33</a>
  ....
</div>
<div class="apparatus">
  ....
  <tr>
    <td><a href="#rs_32" name="app_32">32</a><td>
    <td>in</td>
    <td> - </td>
  </tr>
  <tr>
    <td><a href="#rs_33" name="app_33">33</a><td>
    <td>intellectus cum re que sentitur </td>
    <td>- hom.</td>
    </tr>
  ....
</div>

除了混乱的桌子,这似乎工作正常。一旦我做出了正确的开始,这并不是想象中的巫毒教。

我希望,我也可以指定我的问题并给出一个好的答案。你怎么看?

问候,蒂莫

于 2011-06-30T09:13:50.063 回答