(Why to be) Teaching XSLT

for Digital Arts and Humanities in the age of AI

Elisa Beshero-Bondar

Penn State Erie, The Behrend College | TEI Technical Council

DH 2025 in Lisbon 

Link to these slides:

https://bit.ly/xslt-2025

XSLT templating

<xml>
    <title>A Big Ball of Text with Special Whatsits Inside</title>
    <blob>
        <heading>Blob the Second</heading>
        <ab>Lorem ipsum odor amet, consectetuer adipiscing elit. Ante lobortis ligula accumsan
            conubia; consectetur sem tincidunt.<special whatsIt="magicEgg"/> Rutrum nam neque
            praesent tempor adipiscing volutpat. Habitant feugiat mi nullam proin natoque integer
            cras vitae integer.<special whatsIt="boss"/> Ipsum sit hac enim; aenean inceptos ac
            facilisis habitasse cras! Gravida porttitor fames per ante vestibulum sociosqu.<special
                whatsIt="dragon"/> Platea maecenas at phasellus orci congue ipsum. Sagittis ac
            sagittis cursus; elementum mattis sagittis. Mi nisi vulputate hendrerit ultricies
            dictumst facilisis natoque. Tincidunt vitae natoque, conubia viverra aenean
            gravida.</ab>
    </blob>
    <blob>
        <heading>Blob the Third</heading>
        <ab>Lorem ipsum odor amet, consectetuer adipiscing elit. Ante lobortis ligula accumsan
            conubia; consectetur sem tincidunt.<special whatsIt="jabberwocky"/> Rutrum nam neque
            praesent tempor adipiscing volutpat. Habitant feugiat mi nullam proin natoque integer
            cras vitae integer.<special whatsIt="shield"/> Ipsum sit hac enim; aenean inceptos ac
            facilisis habitasse cras! Gravida porttitor fames per ante vestibulum sociosqu.<special
                whatsIt="invisibilityCloak"/> Platea maecenas at phasellus orci congue ipsum.
            Sagittis ac sagittis cursus; elementum mattis sagittis. Mi nisi vulputate hendrerit
            ultricies dictumst facilisis natoque. Tincidunt vitae natoque, conubia viverra aenean
            gravida.</ab>
    </blob>

</xml>

XSLT templating


    <xsl:template match="/">
        <html>
            <head>
                <title>List from <xsl:apply-templates select="descendant::title"/></title>
                <!-- Link line for CSS would go here... -->
            </head>
            <body>
                <h1>Hello DIGIT 110!</h1>
                <ol>
                  <xsl:apply-templates select="descendant::blob"/>
                </ol>
            </body>
        </html>
    </xsl:template>

    <xsl:template match="blob">
        <li>
            <xsl:apply-templates select="heading"/>
            <ul>
                <xsl:apply-templates select="descendant::special"/>
            </ul>
        </li>
    </xsl:template>

    <xsl:template match="special">
        <li>
            <xsl:apply-templates select="@whatsIt"/>
        </li>
    </xsl:template>

XSLT templating

 

  • Liberation from coding by copying "recipes"
  • Creativity/Intellectual => writing your own script for your purposes
  • Trans-mediation => move from idiosyncratic "bespoke" constructions to conformant
  • Design process
  • Writing process
  • Pipeline process
  • For learning to write well => need time, classes, cultivation of the scholar

John Hughes movie scripts project (Digit Text Analysis): XSLT to SVG

XSLT 3.0 / 4.0

  • Transformations to Knowledge Graphs
  • Transformations to scripts (Cypher) for querying those graphs
  • Transformations for developing RAG systems from XML / TEI
  • XSLT to JSON => much easier to write / adapt / process from XML structures than imperative programming (e.g. Python)
  • XSLT as declaration of graph model structures

XSLT 3.0 / 4.0

  • Write your transformation to produce the language that an LLM can "read"
     
  • XSLT 3.0 to JSON: Optimized for declarative maps and arrays
  <xsl:variable name="nf:graph-model" as="map(*)*">
    <xsl:map>
       <xsl:map-entry key="'document'">
           <xsl:map>
              <xsl:map-entry key="'label'">Document</xsl:map-entry>
              <xsl:map-entry key="'xpathPattern'">document()</xsl:map-entry>
               <xsl:map-entry key="'cypherVar'">doc</xsl:map-entry>
               <xsl:map-entry key="'jsonVar'">value</xsl:map-entry>
       <!-- ebb: Literally 'value' is the value of the document imported on load into neo4j. -->
               <xsl:map-entry key="'primaryKey'">title</xsl:map-entry>
               <xsl:map-entry key="'jsonKeyForPK'">DOCUMENT_TITLE</xsl:map-entry>
            <xsl:map-entry key="'properties'">
                <xsl:map>
                <xsl:map-entry key="'jsonDateTime'">THIS_JSON_DATETIME</xsl:map-entry>
                <xsl:map-entry key="'teiSourceDate'">TEI_SOURCE_OUTPUT_DATE</xsl:map-entry>
                <xsl:map-entry key="'teiSourceVersion'">TEI_SOURCE_VERSION_NUMBER</xsl:map-entry>
                <xsl:map-entry key="'supportInst'">SUPPORTING_INSTITUTION</xsl:map-entry>
                 <xsl:map-entry key="'byline'">PREPARED_BY</xsl:map-entry>
             </xsl:map>
             </xsl:map-entry>
               <xsl:map-entry key="'children'">
                    <xsl:sequence select="
                       array {
                            map {
                               'jsonChildrenKey': 'CONTAINS_PARTS',
                                'childEntityType': 'part',
                                 'relationship': 'HAS_PART',
                                 'isSequence': true()
                                    }
                                }"/>
                 </xsl:map-entry>
                </xsl:map>
            </xsl:map-entry>
           <xsl:map> 
<xsl:map-entry key="'elements_mentioned'">
   <xsl:map>
      <xsl:map-entry key="'isListComprehension'" select="true()"/>
        <xsl:map-entry key="'sourceArrayPath'" select="'TEI_ENCODING_DISCUSSED.ELEMENTS_MENTIONED'"/>
        <xsl:map-entry key="'sourcePropertyKey'" select="'ELEMENT_NAME'"/>
       <!-- EBB: Should we change this to match the name we give in an elementSpec? -->
     </xsl:map>
 </xsl:map-entry> 
 <xsl:map-entry key="'attributes_mentioned'">
   <xsl:map>
      <xsl:map-entry key="'isListComprehension'" select="true()"/>
      <xsl:map-entry key="'sourceArrayPath'" select="'TEI_ENCODING_DISCUSSED.ATTRIBUTES_MENTIONED'"/>
      <xsl:map-entry key="'sourcePropertyKey'" select="'ATTRIBUTE_NAME'"/>
 <!-- EBB: Should we change this to match the name we give in a classSpec / attribute definition? -->
    </xsl:map>
</xsl:map-entry>
<xsl:map-entry key="'speclist_links'">
    <!-- ebb: The <specList> can be children of <p>, or descendants of <p> (within a list[@type='gloss']/item)
The <specDesc> children have a @key that points to the ID of a spec, like so:
<specList>
    <specDesc key="correction" atts="status method"/>
 </specList>
-->
    <xsl:map>
        <xsl:map-entry key="'isListComprehension'" select="true()"/>
        <xsl:map-entry key="'sourceArrayPath'"
            select="'TEI_ENCODING_DISCUSSED.CONTAINS_SPECLISTS.SPECLIST'"/>
        <xsl:map-entry key="'sourcePropertyKey'" select="'ID'"/>
    </xsl:map>
</xsl:map-entry>

Why XSLT helps us, DH scholars/teachers, now 

  • as a efficient means for expressing mapping (to JSON, to CSV, to Cypher)
  • as a writing medium: writerly programming
  • learning and teaching it gives us expressive power
  • to extend our authority to direct the machinery of AI

 

XSLT against infrasomatization?

David Berry, "Against infrasomatization
Towards a critical theory of algorithms" Data Politics, Worlds, Subjects, Rights  (2019)

“Infrasomatizations are vast infrastructural configurations that create networks of cognitive agents to commodify human capacity for reason and thought.“.””h”

XSLT: declarative writing and remediation process, beyond just reaching into an LLM for normalized answers.

Our templating work can be the means of declaring precise intentions and structures.

XSLT-2025

By Elisa Beshero-Bondar

XSLT-2025

A presentation about the significance of XSLT and the importance of teaching it in the time of AI.

  • 81