0

EDIT: solved - incorrect path to the XML document. I'll leave this embarrassing question up in the hope that it may help others.

Environment: eXist-db 4.2.1 , XQuery 3.1, XSLT 2.0

I am building a webpage from a number of templates in eXist-DB, the last of which calls an XSL transformation to produce a fragment of HTML.

The XSL transformation works when I test it outside eXist-DB. At this XSLT fiddle, you have the complete XSLT file and a representative XML doc that should be transformed. It produces the expected HTML without error. Oxygen also produces the transformation without error.

Yet when I execute the transformation in eXist-db XQuery, it signals execution...but it produces no output!

The XAR file for this project (with all modules and files included) can be downloaded here: https://www.dropbox.com/s/gtg4lpv9jsh822e/deheresi-0.1.xar

This is the XQuery transform function that should produce the HTML fragment:

declare function document:doc-xsl-docview($node as node(), 
               $model as map(*), $currentdoc as xs:string)

{   
  let $currentdocnode := doc(concat($globalvar:URIdb,$currentdoc))

  let $xi := concat("xinclude-path=", $globalvar:URIdb)

  let $xsltdoc := doc(concat($globalvar:URIstyles,
                        "ms609__testxsl-withmodes.xsl"))

  let $xsltransform := transform:transform(
                        $currentdocnode, 
                        $xsltdoc,
                        (<parameters>
                            <param name="paramPersonurl" value="{$globalvar:URLperson}"/>
                            <param name="paramPlaceurl" value="{$globalvar:URLplace}"/>
                            <param name="paramDocurl" value="{$globalvar:URLdoc}"/>
                         </parameters>),(),$xi)
  return $xsltransform
 };

This is the HTML (in document.html) calling the function in a template (the last template call). All the other doc-sidebar templates execute perfectly. <div class="col-md-10 document-view"> outputs as an empty div.

<div xmlns="http://www.w3.org/1999/xhtml" data- 
  template="templates:surround" data-template- 
  with="templates/site_wrapper.html" data-template-at="content">

  <div class="col-md-12 document-title">
    <h2>
        <span class="en">Deposition: Arnald Donat</span>
        <span class="fr">Déposition : Arnald Donat</span>
    </h2>
  </div>
  <div class="col-sm-12">
    <div class="col-md-2 sidebar">
        <div data-template="document:doc-sidebar-sub1" data-template-currentdoc="ms609_0013.xml"/>
        <div data-template="document:doc-sidebar-sub2" data-template-currentdoc="ms609_0013.xml"/>
        <div data-template="document:doc-sidebar-sub3" data-template-currentdoc="ms609_0013.xml"/>
        <div data-template="document:doc-sidebar-sub4" data-template-currentdoc="ms609_0013.xml"/>
    </div>
    <div class="col-md-10 document-view">
        <div data-template="document:doc-xsl-docview" data-template-currentdoc="ms609_0013.xml"/>
    </div>
  </div>
</div>

As part of my testing, I did the following: I hardcoded the expected HTML fragment into an XSL file (texthtmlonly.xsl) and called it from the same function instead. It produces the output successfully.

At this point I can't see any reason why the XSL transformation shouldn't work:

  • the XSL and XML files produce valid results without error (outside eXist)

  • the XQuery transform produces results with a hardcoded XSL file

  • the HTML calls all templates without error

Many thanks in advance.

NB: the TEI-XML file (ms609_0013.xml) is temporarily hardcoded for testing in eXist-DB.

EDIT: solved - incorrect path to the XML document. I'll leave this embarrassing question up in the hope that it may help others.

jbrehr
  • 775
  • 6
  • 19
  • I am not familiar with exist-db but in terms of XSLT and XML I notice that your XSLT creates HTML elements in no namespace while your template seems to use the XHTML namespace `http://www.w3.org/1999/xhtml` on the `div` root element. I don't know how the complete content is served up and whether it is done as `text/html` or with an X(HT)ML mime type like `application/xml` or `application/xhtml+xml` but you might want to try whether a consistent use of namespace, i.e. either no XHTML namespace in all fragments or the XHTML namepace in all fragments gives better results. – Martin Honnen Oct 20 '18 at 09:56
  • @MartinHonnen It's good that you point out this inconsistency, thank you. However as regards interfering with output, it hasn't impeded any other XSL stylesheets from producing results before now. This is why I am stumped. – jbrehr Oct 20 '18 at 15:25
  • So what exactly do you see in the output, an empty `div class="col-md-10 document-view"` element? Do you look at the result in a browser with view-source or just at the rendered document? – Martin Honnen Oct 20 '18 at 15:39
  • Yes, en empty `div class="col-md-10 document-view"` in the HTML output. On the other hand,as I stated above, if I take the HTML from an XSL output from Oxygen, and copy/paste it into an XSL document and run it with this same function as a transformation against the same tei-xml fine, it outputs it fine. – jbrehr Oct 20 '18 at 15:48
  • 1
    When I started learning XSL, my instructor repeatedly stated that most errors come down to basic namespaces and paths. In this case it's the latter: I was pointing to the wrong directory for the XML file. – jbrehr Oct 20 '18 at 21:39

0 Answers0