xml hierarchy/xsl processing with tei:note

94 Views Asked by At

I have what I hope is just a symptom of my ignorance and not an impossible problem, but I can't for the life of me make it work.

I am putting together footnotes using the TEI namespace for XML, and the relevant data is packaged as follows:

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

Because this is a new portion of the namespace, I can't use the standard stylesheets and have written the following template to number the notes within the displayed block of text:

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

My issue, however, is with the following set of templates, which attempts to display the body of the notes at the bottom of the page, appropriately numbered:

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

I can either format the code to properly display the numbers through a modification of the code I have in the tei:note template, or I can format the code to properly display the notes, which is what I have here. I need to be able to properly display both the note and numbering, and I understand that the reason why it's not working is that tei:note only appears once in the heirarchy of each line. I know how to do it in a procedural language, but since xsl is functional I'm stumped and none of the methods I've seen suggested (using count(), <xsl:number>, etc) work.

The current output I have is as follows:

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

What I need the results to indicate is the following:

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

There are 1 best solutions below

1
On BEST ANSWER

I think all you need is some code as follows (you will need to adapt the templates to match the elements in your namespace but as your sample does not show a namespace I have worked without one):

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

That transforms the input sample you have posted into the result

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

That is my suggestion for the XSLT part, if I understand the question correctly. As the target format seems to be HTML I wonder however why you don't use an ordered list and list items to number the items.