XQuery imports using catalog

Having trouble installing Oxygen? Got a bug to report? Post it all here.
Tolzidan
Posts: 2
Joined: Tue Feb 09, 2010 4:28 am

XQuery imports using catalog

Post by Tolzidan »

We've got a backend system that can properly resolve XQuery imports and would like to use xml catalogs to do a testing resolution is there a way to properly use the XML Catalogs feature of oxygen to do this.

For example I have a file in an eclipse project at
Project1/my/xquery/file.xql

and a module at
Project2/my/xqm/my.xqm

I want to put a catalog at
Project2/catalog.xml

that can reference the xqm when doing operations in file.xql

file.xql looks like

Code: Select all


xquery version "1.0";
import module namespace my="urn:my-functions" at "customprotocol:///files/*/xqm/my.xqm";
I would like to use a catalog like

Code: Select all


<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.1//EN" "http://www.oasis-open.org/committees/entity/release/1.1/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">

<public publicId="urn:my-functions"
uri="my/xqm/my.xqm"/>

<system systemId="customprotocol:///files/*/xqm/my.xqm"
uri="my/xqm/my.xqm"/>

</catalog>
however neither the system or public is matching and yes this catalog is added as a catalog in the oxygen preferences.

Thank you for your help Paul Ryan
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: XQuery imports using catalog

Post by adrian »

Hello,

In catalog.xml you have to use uri instead of system:

Code: Select all

<uri name="customprotocol:///files/*/xqm/my.xqm"
uri="my/xqm/my.xqm"/>
Let me know if it still does not work.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Tolzidan
Posts: 2
Joined: Tue Feb 09, 2010 4:28 am

Re: XQuery imports using catalog

Post by Tolzidan »

That works for finding the resource however because I have the namespace declared in both the xql and an included xqm with the exact same at it is complaining about a duplicate.

I have file.xql:

Code: Select all


xquery version "1.0";
import module namespace util="urn:my-functions" at "customprotocol:///files/*/xqm/util.xqm";
import module namespace my="urn:my-functions" at "customprotocol:///files/*/xqm/my.xqm";
util.xqm:

Code: Select all


module namespace util="urn:my-utils";

import module namespace my="urn:my-functions" at "customprotocol:///files/*/xqm/my.xqm";
And I'm getting an error in oxygen in file.xqm about duplicates of the functions from my.xqm.

F [Saxon-PE XQuery 9.2.0.3] XQuery static error in #...string($uri)) }; declare#: Duplicate definition of function my:function (see line 10 in file:/Users/me/workspaces/Project2/xqm/my.xqm)

And there are no duplicates, plus the error goes away if I don't import from the top or let the import from the bottom drive the top (e.g. take away the at).
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: XQuery imports using catalog

Post by adrian »

It's in the XQuery specification:
http://www.w3.org/TR/xquery/#doc-xquery-ModuleImport
It is a static error [err:XQST0047] if more than one module import in a Prolog specifies the same target namespace.
So just use different namespaces.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply