0

我有我希望的只是我无知的症状,而不是一个不可能的问题,但我不能为我的生活让它发挥作用。

我正在使用 TEI 命名空间为 XML 整理脚注,相关数据打包如下:

<surface xml:id="EETS.T.29">
            <label>Verse 29</label>
            <graphic url="/Images/IMG_0479.JPG"/>
            <zone>
                <line>
                    <orig><hi>N</hi>ow in <damage>th</damage>e name of oure lord ihesus</orig>
                </line>
                <line>
                    <orig>of right hool herte <ex>&amp;</ex> in our<ex>e</ex>
                        <note place="bottom" anchored="true" xml:id="explanatory">Although “r” on the
                        painted panels of the chapel is consistently written with an otiose mark
                        when it concludes a word, the mark here is rendered more heavily and
                        with a dot indicating suspension above the r. This rendering as “oure”
                        is a linguistic outlier for the area based on the electronic <emph
                        rend="italic">Linguistic Atlas of Late Medieval English</emph>’s
                        linguistic profiles for “oure,” “our,” and “oure.” See eLALME's <ref
                        target="http://archive.ling.ed.ac.uk/ihd/elalme_scripts/mapping/user-defined_maps.html"
                        >User Defined Maps</ref> for more information. Unfortunately the current
                        online version does not allow direct linking between static dotmaps and
                        linguistic profiles.</note> best entent</orig>
                </line>
                <line>
                    <orig>our<ex>e</ex> lyf reme<ex>m</ex>bryng froward and vicious</orig>
                </line>
                <line>
                    <orig>ay contrarye to the comaundement</orig>
                </line>
                <line>
                    <orig>of crist ih<ex>es</ex>u now wyth avisement</orig>
                </line>
                <line>
                    <orig>the lord beseching <gap quantity="2" unit="chars" reason="illegible"
                        /><note place="bottom" anchored="true" xml:id="informational">Trapp
                        suggests "of" here, which fits the space in a way that MacCracken's "in
                        thyn" will not, but it does not seem to fit the admittedly paltry
                        remnants of the text. "In" seems the likely word here, but the text is
                        too damaged to definitively state that this is the case.</note>
                        <damage>mercy and pete</damage></orig>
                </line>
                <line>
                    <orig>our<ex>e</ex> youthe <ex>&amp;</ex> age that we have
                        <damage>myspent</damage></orig>
                </line>
                <line>
                    <orig>wyt<damage>h t</damage>h<damage>is woor</damage>d <damage>mercy
                        knelyng</damage> on oure kne<note place="bottom" anchored="true"
                        xml:id="informational">This change occurs only in the Clopton
                        verses.</note></orig>
                </line>
            </zone>
        </surface>

因为这是命名空间的新部分,所以我不能使用标准样式表并编写了以下模板来对显示的文本块中的注释进行编号:

<xsl:template match="tei:note">
    <xsl:variable name="num">
        <xsl:number count="tei:note" level="any" from="/tei:TEI/tei:sourceDoc/tei:surfaceGrp/tei:surface"/>
    </xsl:variable>
    <xsl:variable name="panel_name">
        <xsl:value-of select="concat(../../../../@xml:id,$num)"/>
    </xsl:variable>
    <xsl:choose>
        <xsl:when test="@xml:id ='explanatory'">
            <span class="explanatory"><sup><a><xsl:attribute name="href"><xsl:value-of select="concat('#fn',$num)"/></xsl:attribute><xsl:attribute name="id"><xsl:value-of select="$panel_name"/></xsl:attribute><font size="-1"><xsl:value-of select="$num"/></font></a></sup></span>
        </xsl:when>
        <xsl:when test="@xml:id ='informational'">
            <span class="informational"><sup><a><xsl:attribute name="href"><xsl:value-of select="concat('#fn',$num)"/></xsl:attribute><xsl:attribute name="id"><xsl:value-of select="$panel_name"/></xsl:attribute><font size="-1"><xsl:value-of select="$num"/></font></a></sup></span>
        </xsl:when>
        <xsl:otherwise/>
    </xsl:choose>
</xsl:template>

然而,我的问题在于以下一组模板,它试图在页面底部显示注释的正文,并适当编号:

        <xsl:template name="makeNotes">
            <xsl:variable name="num" select="count(.//tei:note)"/> 
            <xsl:variable name="panel_name">
                <xsl:value-of select="concat(@xml:id,$num)"/>
            </xsl:variable>

            <div class="notes">
                <div class="noteHeading">Notes</div>

                <xsl:call-template name="loop"> 
                    <xsl:with-param name="i" select="number(1)"/>
                    <xsl:with-param name="max" select="$num"/> 
                </xsl:call-template>
           </div>    
        </xsl:template>
   <xsl:template name="loop"> 
        <!--recursive loop until done--> 
        <xsl:param name="i"/> 
        <xsl:param name="max"/> 

        <xsl:for-each select=".//tei:orig">
            <xsl:if test="tei:note">
                <xsl:if test="$i &lt;= $max"> 
                    <!-- Repeated content Here --> 
                    <!-- use value-of i to get loop index --> 
                    <div class ="note"><span class="noteLabel"><xsl:attribute name="id"><xsl:value-of select="concat('fn',$i)"/></xsl:attribute><xsl:value-of select="$i"></xsl:value-of>.</span><div class="noteBody"><xsl:value-of select="tei:note"/></div></div>
                    <xsl:call-template name="loop"> 
                        <xsl:with-param name="i" select="$i + 1"/> 
                        <xsl:with-param name="max" select="$max"/> 
                    </xsl:call-template> 
                </xsl:if> 
            </xsl:if>
        </xsl:for-each>

我可以通过修改 tei:note 模板中的代码来格式化代码以正确显示数字,或者我可以格式化代码以正确显示注释,这就是我在这里所拥有的。我需要能够正确显示注释和编号,并且我知道它不起作用的原因是tei:note它只在每行的层次结构中出现一次。我知道如何用程序语言来做到这一点,但是由于 xsl 是功能性的,我很难过,而且我所看到的任何方法(使用count(),<xsl:number>等)都不起作用。

我目前的输出如下:

<div class="note"><span class="noteLabel" id="fn1">1.</span>
    <div class="noteBody">Although "r" on the
      painted panels of the chapel is consistently written with an otiose mark
      when it concludes a word, the mark here is rendered more heavily and
      with a dot indicating suspension above the r. This rendering as "oure"
      is a linguistic outlier for the area based on the electronic Linguistic Atlas of Late Medieval English's
      linguistic profiles for "oure," "our," and "oure." See eLALME's User Defined Maps for more information. Unfortunately the current
      online version does not allow direct linking between static dotmaps and
      linguistic profiles.</div>
  </div>
  <div class="note"><span class="noteLabel" id="fn1">1.</span>
    <div class="noteBody">Trapp
      suggests "of" here, which fits the space in a way that MacCracken's "in
      thyn" will not, but it does not seem to fit the admittedly paltry
      remnants of the text. "In" seems the likely word here, but the text is
      too damaged to definitively state that this is the case.</div>
  </div>
  <div class="note"><span class="noteLabel" id="fn1">1.</span>
    <div class="noteBody">This change occurs only in the Clopton
      verses.</div>
  </div>

我需要结果表明如下:

<div class="note"><span class="noteLabel" id="fn1">1.</span>
    <div class="noteBody">Although "r" on the
      painted panels of the chapel is consistently written with an otiose mark
      when it concludes a word, the mark here is rendered more heavily and
      with a dot indicating suspension above the r. This rendering as "oure"
      is a linguistic outlier for the area based on the electronic Linguistic Atlas of Late Medieval English's
      linguistic profiles for "oure," "our," and "oure." See eLALME's User Defined Maps for more information. Unfortunately the current
      online version does not allow direct linking between static dotmaps and
      linguistic profiles.</div>
  </div>
  <div class="note"><span class="noteLabel" id="fn2">2.</span>
    <div class="noteBody">Trapp
      suggests "of" here, which fits the space in a way that MacCracken's "in
      thyn" will not, but it does not seem to fit the admittedly paltry
      remnants of the text. "In" seems the likely word here, but the text is
      too damaged to definitively state that this is the case.</div>
  </div>
  <div class="note"><span class="noteLabel" id="fn3">3.</span>
    <div class="noteBody">This change occurs only in the Clopton
      verses.</div>
  </div>
4

1 回答 1

0

我认为您所需要的只是一些如下代码(您需要调整模板以匹配命名空间中的元素,但由于您的示例未显示命名空间,因此我没有使用它):

<xsl:stylesheet version="2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html" indent="yes"/>

<xsl:template match="surface">
  <xsl:apply-templates select=".//orig[note]" mode="list"/>
</xsl:template>

<xsl:template match="orig" mode="list">
<div class ="note"><span class="noteLabel" id="fn{position()}"><xsl:value-of select="position()"></xsl:value-of>.</span><div class="noteBody"><xsl:value-of select="note"/></div></div>
</xsl:template>

</xsl:stylesheet>

这会将您发布的输入样本转换为结果

<div class="note"><span class="noteLabel" id="fn1">1.</span><div class="noteBody">Although “r” on the
      painted panels of the chapel is consistently written with an otiose mark
      when it concludes a word, the mark here is rendered more heavily and
      with a dot indicating suspension above the r. This rendering as “oure”
      is a linguistic outlier for the area based on the electronic Linguistic Atlas of Late
      Medieval English’s
      linguistic profiles for “oure,” “our,” and “oure.” See eLALME's User Defined Maps
      for more information. Unfortunately the current
      online version does not allow direct linking between static dotmaps and
      linguistic profiles.
   </div>
</div>
<div class="note"><span class="noteLabel" id="fn2">2.</span><div class="noteBody">Trapp
      suggests "of" here, which fits the space in a way that MacCracken's "in
      thyn" will not, but it does not seem to fit the admittedly paltry
      remnants of the text. "In" seems the likely word here, but the text is
      too damaged to definitively state that this is the case.
   </div>
</div>
<div class="note"><span class="noteLabel" id="fn3">3.</span><div class="noteBody">This change occurs only in the Clopton
      verses.
   </div>
</div>

如果我正确理解了这个问题,这就是我对 XSLT 部分的建议。由于目标格式似乎是 HTML,但我想知道为什么您不使用有序列表和列表项目来对项目进行编号。

于 2014-06-09T17:50:57.707 回答