1

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

I am attempting to transform an XML document with an XSLT 2.0 stylesheet, triggered by eXist-DB/Query 3.1. I am receiving the following error

err:XPDY0002 Undefined context sequence for 'child::{}xinclude-path' 
[at line 271, column 48, source: /db/apps/deheresi/modules/document.xql]

This error points to the following XQuery in the document.xqm module, line 217 being </parameters>),(),xinclude-path=$globalvar:URIdb):

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

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

  let $xsltransform := transform:transform(
                        $currentdocnode, 
                        concat($globalvar:URIstyles,
                        "ms609__testxsl-withmodes.xsl"),
                        (<parameters>
                            <param name="paramPersonurl" value="{$globalvar:URLperson}"/>
                            <param name="paramPlaceurl" value="{$globalvar:URLplace}"/>
                            <param name="paramDocurl" value="{$globalvar:URLdoc}"/>
                         </parameters>),(),xinclude-path=$globalvar:URIdb)
return $xsltransform
 };

To explain the above variables:

  • $currentdoc is a document name that I turn into a eXist-DB node as $currentdocnode.

  • XML documents are kept in $globalvar:URIdb = /db/apps/deheresi/data

  • XSLT styles are kept in $globalvar:URIstyles doc = /db/apps/deheresi/styles

I'm using the transformation with serialization for xi:includes:

transform:transform($node-tree as node()*, $stylesheet as item(), 
                $parameters as node()?, $attributes as node()?, 
                $serialization-options as xs:string?) as node()?

I need to pass the xinclude-path=$globalvar:URIdb in order to tell eXist-DB where to process the xi:includes inside my the XML documents.

I should note that the $globalvar are strings, not nodes. If I need nodes, I 'convert' them locally at the moment as in $currentdocnode above.

Thanks in advance for helping puzzle this error.

jbrehr
  • 775
  • 6
  • 19

1 Answers1

1

The docs for transform:transform note that the serialization options should be a string:

transform:transform($node-tree as node()*, $stylesheet as item(), 
                $parameters as node()?, $attributes as node()?, 
                $serialization-options as xs:string?) as node()?

You need to wrap you parameter in quotes and concatenate with your global variable:

concat(`xinclude-path=`, $globalvar:URIdb)
wst
  • 11,681
  • 1
  • 24
  • 39
  • That solved it, but produced a new protocol error posted here https://stackoverflow.com/questions/52897533/exist-db-xquery-xsl-transform-unable-to-set-up-transformer-no-protocol – jbrehr Oct 19 '18 at 17:44