How to refer to the n attribute in the lg element of TEI xml document in XSLT to create a LaTeX output (for using reledmac to make PDF)

Viewed 38

I want to ultimately print the verse number, e.g. §1, encoded in the XML as <lg n="1"> , in my pdf output. Here's an example of my XML document:

        <teiHeader>
            ...
        </teiHeader>
        <text>
            ...
            <body>
                <head>
                    ...
                </head>
                <div>
                    <lg n="1">
                        <l n="1">
                           verse one line one of the poem</l>
                        <l n="2">
                            verse one line two</l>
                        <l n="3">...ditto </l>
                        <l n="4">...ditto </l>
                    </lg>
                    <lg n="2">
                        <l n="1">...
                    </lg>
...

I am preparing a critical edition of a poem of this structure, and since I am a novice to XML, TEI, XSLT, and LaTeX, I cannot figure out how to reference the n="1" part in the xslt so that LaTeX prints it. I am trying to use the stylesheet posted on TEI Critical Apparatus Toolbox that transforms XML into LaTeX with the reledmac package (the link to the XSLT file is under "Advanced Customisation"). The relevant part seems to be these lines, though I don't understand how this works. I just want to tweak it so that my verse numbers, and perhaps even my line numbers, can be referenced and printed:

<!-- inserts linegroup into document-->
  <xsl:template match="tei:lg">

    <!-- lg is a pain because it can occur in p (or not), but in tex it generates a stanza structure which must never be inside a paragraph
    I've tried closing the parent paragraph and re-opening one, but it's not enough. 
    If the lg are inside a quotation, for instance, we need to have some more complicated handling.
    -->

    <xsl:choose>
      <xsl:when test="not(ancestor::tei:rdg)">
        <xsl:if test="ancestor::tei:p and not(preceding-sibling::tei:lg)">
          <!-- In TEI an lg can occur within a p, while in LaTeX a stanza cannot occur within a pstart. The only solution I came up with was to close then re-open the current paragraph. 
        Warning: this can create a problem in the .tex file when the lg occurs at the very beginning or end of the paragraph. -->
          <xsl:text>
                \pend </xsl:text>
        </xsl:if>
        <xsl:text>                     
        \stanza[ ] </xsl:text>

        <!-- this is not good; TODO: do better. -->
        <xsl:if test="ancestor::tei:cit">
          <xsl:if
            test="ancestor::tei:quote[position() = 1]/descendant::node()[name() = 'lg'][position() = 1] = self::node()">
            <xsl:text>\edlabel{cit_</xsl:text>
            <xsl:number select="ancestor::tei:quote[position() = 1]" level="any"/>
            <xsl:text>_start}</xsl:text>
          </xsl:if>
        </xsl:if>

      </xsl:when>
      <xsl:otherwise>
        <xsl:text> </xsl:text>
      </xsl:otherwise>
    </xsl:choose>
1 Answers

Inside of your template matching a tei:lg element you can select @n in XPath to select the attribute named n and in XSLT output e.g. <xsl:value-of select="@n"/> to output the attribute's value (e.g. 1).

Related