TEI关键设备,双端点连接;如何处理 XSL 生成 HTML

发布于 2024-11-17 20:01:04 字数 843 浏览 2 评论 0原文

我必须将以下 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 的附加应用程序元素。

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

TEI 中一定有关于这种标准方法的解决方案,但我找不到它,如果有人有任何建议,我会非常高兴。

预先非常感谢, 蒂莫

i have to process the follwing XML structure:

<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>

into something like:

<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>

Whereas the 1 is meant to be superscript.

I have no problem building the actual apparat but on building the footnotes, because the Information about the relevant anchors comes from the external apparat-elements.

Aside i have to mention that there can be an additional app-Element from anchor-1 to anchor-4 at the same time.

I have seen a question on how to choose the text between such pseudo-overlapping elements here and it helped me a lot. But i cant find any solutions for this problem.

There must be a solution on such a standard method in TEI but i cant find it and i would be very happy, if anyone would have any suggestions.

Many thanks in advance,
Timo

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱娆 2024-11-24 20:01:04

这是一个更复杂的 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>

除了混乱的表之外,这似乎工作正常。一旦我有了正确的开始,这并不是想象中的巫术。

我希望,我可以具体说明我的问题并给出一个很好的答案。
你觉得怎么样?

问候,
蒂莫

So here is a more complex example of the XML which includes the overlap problem as well.

<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>

My XSLT Templates so far:

    <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>

And the resulting Output should look like the following:

<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>

Except for the chaotic table this seems to work fine. It wasn't that voodoo as is thought of, once i had made the right start.

I hope, i could specify my question and gave a good answer, too.
What du you think?

greetings,
Timo

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文