0

私は自分の無知の単なる症状であり、不可能な問題ではないと願っていますが、私の人生ではそれを機能させることはできません.

XML の TEI 名前空間を使用して脚注をまとめています。関連データは次のようにパッケージ化されています。

<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、各行の階層に 1 回しか表示されないことにあると理解しています。私は手続き型言語でそれを行う方法を知っていますが、 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 に答える