0

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

In eXist-db I am loading an XSLT file which includes a reference to a collection in eXist (in order to perform a search on documents found there, using a key). This reference seems to throw an error from Saxon.

Exception while transforming node: Exception thrown by URIResolver

  • XML docs are located at /db/apps/deheresi/data/
  • XSLT docs are located at /db/apps/deheresi/data/styles

In the transform function, I am passing a parameter from XQuery to the XSLT file for the absolute path to the data folder:

<param name="paramDatauri" 
  value="xmldb:exist:///db/apps/deheresi/data/"/>

In the XSLT file, this parameter is received and injected into a variable:

 <xsl:variable name="coll" 
  select="collection(concat($paramDatauri,'?select=*.xml'))"/>

I've looked at possible parameters that Saxon might need, but I've not identified any that can resolve this problem.

EDIT #1: I've tried to pass an attribute in XQuery transform()

 <attributes>
    <attr name="paramSax" value="COLLECTION_URI_RESOLVER"/>
 </attributes>

per Saxonica documentation, but I get the message

 `Unable to set up transformer: Unknown configuration property`

I don't know if this is redundant/unnecessary, or if I've configured the attribute incorrectly.

EDIT #2: I've attempted to hardcode the absolute path into the XSL file:

<xsl:variable name="coll" 
  select="collection('xmldb:exist:///db/apps/deheresi/data/?select=*.xml')"/>

As well a relative path:

<xsl:variable name="coll" 
  select="collection('/db/apps/deheresi/data/?select=*.xml')"/>

Always returning the same error Exception thrown by URIResolver.

This is the first time I've tried to use a collection() function within a XSLT within eXist-db.

Many thanks.

jbrehr
  • 775
  • 6
  • 19
  • Perhaps others will provide a fuller reply, but all I know about the issue is described here: https://markmail.org/message/l6rfv6hw5ojxbt7v. The O'Reilly eXist book p. 243 has similar info. – Joe Wicentowski Oct 22 '18 at 19:36
  • @joewiz indeed the O'Reilly book is where I began investigating, where it states: "The collection function does not behave as you would expect: it does not return any direct information about the collections in the database. It can, however, be used as Saxon intended it. For more information about this, please refer to the Saxon documentation." So I looked through Saxon documentation as much as I can (I am way out of my depth by wading into Saxon - I'm beginning to just throw things against the wall). – jbrehr Oct 22 '18 at 19:44
  • Yeah, the eXist book should’ve been more explicit. Hope we get a clear answer! – Joe Wicentowski Oct 22 '18 at 21:23
  • Much the same problem with the official documentation https://exist-db.org/exist/apps/doc/xsl-transform – jbrehr Oct 22 '18 at 21:27
  • Saxon's `collection()` function can not work with eXist-db's `collection()` function. But looking at similar questions you figured it out already? You should take results from eXist's xquery engine as result for the XSLT processing instead. – DiZzZz Oct 24 '18 at 10:58
  • @DiZzZz yes, I learned the hard way why there is a documentation gap about this :) But answers to other questions have helped me see several different options, some of which I've now deployed. – jbrehr Oct 24 '18 at 11:18

0 Answers0