Reputation: 491
I have an eXist database that I'm rendering to html through a single xql that calls to an xslt page, via this block of code:
xquery version "3.1";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace m = "http://www.minorworksoflydgate.net/model";
declare default element namespace "http://www.w3.org/1999/xhtml";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "xhtml";
declare option output:media-type "application/xhtml+xml";
declare option output:omit-xml-declaration "no";
declare option output:html-version "5.0";
declare option output:indent "no";
declare option output:include-content-type "no";
declare variable $exist:root as xs:string :=
request:get-parameter("exist:root", "xmldb:exist:///db/apps");
declare variable $exist:controller as xs:string :=
request:get-parameter("exist:controller", "/mwjl-app");
declare variable $text := request:get-data(); (:this variable allows the pipeline to work:)
let $xsl := xs:anyURI($exist:root || $exist:controller || "/data/stylesheets/wrapper.xsl")
return
transform:transform($text, $xsl, ())
To transform a TEI XML page, the bulk of which is a list formatted like this:
<list type="index">
<item n="draft" xml:id="6561"><emph rend="italic">A lamentacioun of our lady Maria</emph>
<ref target="http://www.dimev.net/record.php?recID=6561">(DIMEV: 6561)</ref>
</item>
<list>
<item>
<ref target="/Quis_Dabit/Jesus_College_Q_G_8/Jesus_Q_G_8_f19v.html">Cambridge, Jesus College Q.G.8</ref>
</item>
<item><ref
target="/Quis_Dabit/British_Library_Harley_2251/British_Library_Harley_2251_f42v.html"
>London, British Library Harley 2251</ref></item>
<item><ref
target="/Quis_Dabit/British_Library_Harley_2255/British_Library_Harley_2255_f66v.html"
>London, British Library Harley 2255</ref></item>
<item><ref target="/Quis_Dabit/Laud_683/Laud_683_f78r.html">Oxford, Bodleian
Library Laud misc. 683</ref></item>
<item><ref target="/Quis_Dabit/St_John_56/St_John_56_73v.html">Oxford, St.
John's College 56</ref></item>
</list>
<item n="draft" xml:id="747"><emph rend="italic">A Mumming at Eltham</emph><ref
target="http://www.dimev.net/record.php?recID=747"> (DIMEV:
747)</ref></item>
<list>
<item><ref target="/Mumming_Eltham/Trinity_R_3_20/Trinity_R_3_20_f19r.html"
>Cambridge, Trinity College R.3.20</ref></item>
<item><ref
target="/Mumming_Eltham/British_Library_Additional_29729/Add_29729_f135v.html"
>London, British Library Addit. 29729</ref></item>
</list>
</list>
This works, but on a few of my pages the xml, which I created out of what was originally a set of SQL results, is noticeably slow if it gets over 8000 lines. Much more so than a straight Saxon transformation into html would be. It's a single xml page, so indexing does not seem to do much. How do I optimize the xql to render the page quickly, or am I better off just setting eXist aside?
ETA: The xsl for this particular bit is as follows. It's not the entirety of the xsl files -- those are split between a file for the header and a file for the body in a wrapper file that the xql calls to -- but it might help.
The wrapper file is as follows:
<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:teix="http://www.tei-c.org/ns/Examples" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:rng="http://relaxng.org/ns/structure/1.0" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="#default html a fo rng tei teix" version="3.0">
<xsl:include href="header.xsl"/>
<xsl:include href="body.xsl"/>
</xsl:stylesheet>
The germane bit of the body.xsl (the header.xsl file is rendered on pages that load fine so I don't think it is the issue) is as follows:
<xsl:template match="tei:list">
<xsl:choose>
<xsl:when test="@rend='ordered'">
<ol>
<xsl:apply-templates/>
</ol>
</xsl:when>
<xsl:when test="@type='index'">
<ul class="index">
<xsl:apply-templates/>
</ul>
</xsl:when>
<xsl:when test="@type='simple'">
<ul class="nodisplay">
<xsl:apply-templates/>
</ul>
</xsl:when>
<xsl:when test="@xml:id='compare'">
<ul class="nodisplay">
<xsl:apply-templates/>
</ul>
</xsl:when>
<xsl:when test="@type='bibliography'">
<ul class="nodisplay bibliography">
<xsl:apply-templates/>
</ul>
</xsl:when>
<xsl:otherwise>
<ul>
<xsl:apply-templates/>
</ul>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tei:list[@xml:id = 'bullet_list']/tei:item">
<li>
<xsl:attribute name="class">
<xsl:text>bullet_list</xsl:text>
</xsl:attribute>
<xsl:apply-templates/>
</li>
</xsl:template>
<xsl:template match="tei:item">
<xsl:choose>
<xsl:when test="@xml:id">
<li>
<a>
<xsl:attribute name="name">
<xsl:value-of select="@xml:id"/>
</xsl:attribute>
<xsl:attribute name="class">
<xsl:text>anchor</xsl:text>
</xsl:attribute>
<xsl:apply-templates/>
</a>
</li>
</xsl:when>
<xsl:otherwise>
<li>
<xsl:apply-templates/>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
I think the issue is the number of list/items combinations the code is iterating through, but I'm not sure how you resolve that if an index doesn't work and given the way xsl handles a document.
Upvotes: 0
Views: 56