2011-06-29 18 views
1

处理,我必须在follwing XML结构的过程:TEI关键设备,双端点附件;如何使用XSL生成HTML

<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,就是要标。

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

除此之外,我不得不提到,可以有一个额外的应用程序元素从锚-1到锚-4在同一时间。

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

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

提前许多感谢, 蒂莫

+2

你有一个很好的问题的开始,但我发现很难遵循。你能提供迄今为止尝试过的XSL吗?另外,我不明白你的意思是“你可以提供一个例子吗?”可以是一个额外的应用程序 - 元素从锚-1到锚-4在同一时间吗? – cordsen

+0

@cordsen:好的,现在我知道我不是唯一一个对此感到困惑的人:) –

+0

sry,我确实在一个很好的路上。我明天会告诉你我自己的解决方案,或者制造更多混乱 – Timo

回答

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> 

除乱表这似乎很好地工作。这不是我想象的巫术,只要我做出了正确的开始。

我希望我能指出我的问题并给出一个很好的答案。 你觉得怎么样?

问候, 蒂莫