Project

Profile

Help

Support #4809

How to use collections in Saxon-JS?

Added by Jerry Jackson about 1 month ago. Updated 29 days ago.

Status:
New
Priority:
Low
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
2020-10-26
Due date:
% Done:

0%

Estimated time:
Applies to JS Branch:
Fix Committed on JS Branch:
Fixed in JS Release:
SEF Generated with:
Company:
-
Contact person:
-
Additional contact persons:
-

Description

I have a very simple stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
   <xsl:template name="xsl:initial-template">
      <xsl:apply-templates select="collection('file:/C:/temp/mydir')"/>
   </xsl:template>
</xsl:stylesheet>

When I run this with Saxon-JS on the command-line (xslt3 "-xsl:test.xsl"), I get this error:

Transformation failure: Error FODC0002 at test.xsl#4
    Unknown collection (no collectionFinder supplied)
Transformation failed: Error FODC0002 at test.xsl#4
    Unknown collection (no collectionFinder supplied)

I have tried to run it with the API, and reading the documentation I see I can supply a collectionFinder in the transform method, but i'm not sure on how to implement it to get the same result as when running it in Saxon-Java.

History

#1 Updated by Michael Kay about 1 month ago

Another user has been asking about this at

https://saxonica.plan.io/boards/3/topics/8050

and you may find that discussion helpful.

Essentially the implementation of collection() in Saxon-JS is absolutely minimal, since it just delegates the entire logic to the user-supplied CollectionFinder. To replicate the Saxon-J behaviour of processing directory contents recursively you'll have to implement it yourself. Sorry about that.

#2 Updated by Debbie Lockett about 1 month ago

  • Project changed from Saxon to Saxon-JS

#3 Updated by Jerry Jackson about 1 month ago

Michael Kay wrote:

Another user has been asking about this at

https://saxonica.plan.io/boards/3/topics/8050

and you may find that discussion helpful.

Essentially the implementation of collection() in Saxon-JS is absolutely minimal, since it just delegates the entire logic to the user-supplied CollectionFinder. To replicate the Saxon-J behaviour of processing directory contents recursively you'll have to implement it yourself. Sorry about that.

Can you show a minimal example of how to implement collectionFinder? From looking at the other question, it seems the expected return type is an array of whatever Saxon.getResource() returns, but my attempts to make it work have failed so far, and unfortunately the error messages are rather cryptic.

#4 Updated by Martin Honnen 29 days ago

As for a smaller sample using collectionFinder, see whether https://saxonica.plan.io/issues/4797#note-3 helps. It uses Saxon.getResource and await to preload an array of two document nodes and makes them available from collectionFinder.

Please register to edit this issue

Also available in: Atom PDF Tracking page