Support for .jq and .jsd files

Bug #1192043 reported by Chris Hillery
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zorba
Fix Released
Critical
Chris Hillery

Bug Description

The current module mechanisms only work with .xq and .xsd files. DECLARE_ZORBA_MODULE() and DECLARE_ZORBA_SCHEMA() will enforce those extensions, and the URI mappers inside Zorba attempt to find modules and schemas with those extensions.

For JSONiq those are inappropriate; we should support .jq and .jsd as well, ideally without causing a large number of additional lookup attempts.

Related branches

Revision history for this message
Chris Hillery (ceejatec) wrote :

One way to do this would be to hash the module/schema URI and use that hash to look up the correct file on disk. That would actually reduce the number of lookups currently done, since we currently attempt to file the file with a .xq extension and then again without the .xq extension.

We would not need to hash whether the module/schema was JSONiq or XQuery, unless for some bizarre reason we need to have an XQuery module and a JSONiq module with the same URI (hopefully not!). However, we would need to hash whether the URI was a module or schema (or "something else", for fetch()), because we do have schemas and modules with shared URIs.

It's not completely clear how this would play with the module-versioning mechanism.

Changed in zorba:
assignee: nobody → Chris Hillery (ceejatec)
milestone: none → 3.0
importance: Undecided → Critical
Revision history for this message
Chris Hillery (ceejatec) wrote :

Needs to feed back detected language to translator.

Needs to be easy to find the actual .xq/.jq file on URI path, so the hashing approach may not be desirable.

Possibly an index would be a good idea, either on-disk or in-memory. Would probably need to be optional to make it easier for people to install their own modules.

Maybe just having a bunch of disk stat()s isn't that big a deal, although we do need to ensure that all possible on-disk locations are exhausted before any network attempts are made.

Chris Hillery (ceejatec)
Changed in zorba:
status: New → In Progress
Revision history for this message
Chris Hillery (ceejatec) wrote :

Exploration indicates that the current lookup process does exhaust filesystem locations before trying network.

After some consideration, I have left the mechanism effectively unchanged. The only modification was to change the extension that modules/schemas use on URI_PATH to .module/.schema, rather than .xq/.xsd. This is basically a clarification that a Zorba module or schema may be written in several languages, not just XQuery/XML Schema.

The downsides of installing files with "correct" extensions (eg., .xq/.jq/.xsd/.jsd) is that it requires additional filesystem lookups, and more network attempts if it is not found locally. By using a single extension, we can support an arbitrary number of languages without increasing the number of stats.

Also, for modules, it is not clear how to achieve the suggested goal of feeding the file extension back to translator so it can use the "right parser". The better approach for that issue is to ensure that all Zorba modules have a correct version declaration on the front line; I am adding code for that. There is no equivalent way to ensure schemas have a correct form, but unlike modules we use different mechanisms for loading JSound and XSD schemas.

Chris Hillery (ceejatec)
Changed in zorba:
status: In Progress → Fix Committed
Changed in zorba:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.