0

XSLT 2.0, stylesheet and data at https://xsltfiddle.liberty-development.net/bFDb2D3/4

I am transforming medieval documents encoded in tei-xml into webpages where the user can toggle between two different views of the documents, as well as see the translation and various footnotes (eg). This requires multiple layers of processing to output:

  • Two latin versions ('inter' and 'diplo') between which the user can toggle (derived from the same tei markup)
  • Translated version with almost no transformations (just paragraph formatting and italics)
  • Critical apparatus using footnoting # a, b, c, etc.
  • Historical footnotes using footnoting # 1, 2, 3, etc.

I am using modes in order to handle the levels of processing, and each mode on its own works fine, but together they are missing outputs.

What should output:

  1. <div class="inter"><p> with all transformations mode inter + fn-add-marker [this should contain <a href>, superscript letters and numbers in text]

  2. <div class="diplo"><p> with all transformations mode diplo + fn-add-marker [this should contain [text] , line numbers, superscript letters and numbers in text]

  3. <div><p> with translations

  4. <div> with critical apparatus

  5. <div> with footnotes

The XSLTfiddle output is:

  1. URL and superscript letters ok! missing superscript numbers (mode fn-add-marker)
  2. Superscript letters ok! Line # and [text] ok except where inside <persName> or <placeName> (ie.<xsl:template match="tei:lb"> <xsl:template match="tei:supplied">) and missing superscript numbers (mode fn-add-marker)
  3. ok!
  4. ok!
  5. ok!

With respect to #2, the missing line # and [text] appear to be a result of the templates that treat <persName> and <placeName> not handing off to other templates? (templates at lines 173-218)

All templates concerning mode fn-add-marker are at lines 41-77.

Many thanks in advance.

jbrehr
  • 775
  • 6
  • 19

1 Answers1

3

Basically in XSLT 2, once you work with named modes, you need to make sure in a template belonging to a certain mode, having e.g. mode="foo", that you use e.g. mode="foo" or more general mode="#current" on any xsl:apply-templates inside to ensure processing continues in that mode. See https://www.w3.org/TR/xslt20/#element-apply-templates for details.

At https://xsltfiddle.liberty-development.net/gWmuiK7 I have tried XSLT to fix your stylesheet and then at https://xsltfiddle.liberty-development.net/bFDb2D3/5 you can see the result of applying the fixed stylesheet. Not sure whether that programmatic approach is the right tool but it might help to demonstrate the suggested use mode mode on xsl:apply-templates.

Then I think you need to make sure you process the added markers in the two new modes:

<!-- adds fn numbers -->
<xsl:template match="tei:date[@type='deposition_date']" mode="inter dilpo">
    <xsl:apply-templates mode="#current"/>
    <xsl:apply-templates select="." mode="number"/>
</xsl:template>

<xsl:template match="tei:note[@type='public'] | tei:fn-marker" mode="inter diplo">
    <xsl:apply-templates select="." mode="number"/>
</xsl:template>

<xsl:template match="tei:date[@type='deposition_date'] |  tei:note[@type='public'] | tei:fn-marker" mode="number">
    <sup>
       <xsl:number count="tei:date[@type='deposition_date'] |  tei:note[@type='public'] | tei:fn-marker" format="1" level="any"/>
    </sup>
</xsl:template>
<!-- end of footnote transformations -->

https://xsltfiddle.liberty-development.net/bFDb2D3/6 lines 51 to 66.

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110
  • Right, thanks. So, what I don't see is how to get the mode `fn-add-marker` to then output - at what point does it become 'current'. It's as though the processor doesn't see it and I haven't been able to find the entry point to call it..as it needs to perform the transformation twice (for 'inter' and 'diplo' outputs). – jbrehr Oct 22 '18 at 08:38
  • 1
    See the edit to the answer, if I am not lost then you don't need to change that `fn-add-marker` mode, instead you need to make sure the code for converting markers and notes to numbers is now applied in the two modes `inter` and `diplo` you introduced. – Martin Honnen Oct 22 '18 at 09:08
  • Ah, I had the logic inverted (and no, you are not lost). I also didn't know one could put two modes in `mode`. This is fantastic, and I learned a lot again. Thanks. – jbrehr Oct 22 '18 at 09:11