[xquery-talk] Galax, XQuery! and schema type matching

Michael Kay mike at saxonica.com
Fri Jun 8 11:12:37 PDT 2007

Here is a working example for Saxon-SA.
Schema test.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
<xsd:element name="doc">
    <xsd:choice maxOccurs="unbounded">
      <xsd:element name="a" type="asdf:type1"/>
      <xsd:element name="b" type="asdf:type2"/>
<xsd:simpleType name="type1">
  <xsd:restriction base="xsd:integer"/>
<xsd:simpleType name="type2">
  <xsd:restriction base="xsd:date"/>
Source test.xml:
<doc xmlns="http://www.asdf.com/">
Query test.xq:
import schema namespace asdf = "http://www.asdf.com/" at "test.xsd";
for $elem in */* return
  typeswitch ($elem)
  case element(*, asdf:type1) return element type1 {}
  case element(*, asdf:type2) return element type2 {}
  default return element default {}
Command line:
java -cp c:\saxon-build\\saj\saxon8sa.jar;c:\saxon-licenses
net.sf.saxon.Query -sa -val -s  test.xml test.xq
<?xml version="1.0" encoding="UTF-8"?>
The easiest way to get it wrong is to forget to ask for the input document
to be validated (-val option).
Michael Kay


From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On Behalf
Of Vitali Gontsharuk
Sent: 08 June 2007 08:24
To: talk at x-query.com
Subject: [xquery-talk] Galax, XQuery! and schema type matching


I'm having two problems which I could not solve until now.

The first problem is the following: schema type matching doesn't work for me
in typeswitch constructs. By that I mean constructs of the following form: 

typeswitch ($elem)
case element(*, asdf:type1) return element type1 {}
case element(*, asdf:type2) return element type2 {}
default return element default {}

Here, asdf is the namespace prefix of the imported schema. I've tried this
both with the schema-aware version of saxon and with Galax. I'm doing this
the way this is described in the XQuery spec. Could someone please point me
to the problem by giving a working example. Because Saxon is a 100%
standard-conform XQuery implementation, I assume that I've made some
syntactical mistake. 

The second problem is about the XQuery! implementation in Galax. I'm using
this XQuery extension to make changes in the XML node sets but this doesn't
work for me. Here is the example which I'm testing with. It has been
published in a presentation by Jerome Simeon (one of the leaders of the
Galax project). Here is the script: 

(: Declare our counter :)
declare variable $counter := element counter { 0 };

(: Increment the counter :)
declare function local:getnext() as xs:integer {
 replace { $counter/node() } with { $counter/node() + 1 },

I'm getting the following error:

Lexing Error: 3 Found QName while in operator state [File "bib.xq", line 6,

characters 9-10:]
I'm using the following command to interpret this script: 

galax-run -output-xml bib.xml.result.xml -language xquerybang bib.xq
Here is the link to the presentation by Jerome Simeon from which I extracted
the above sample script:

I will be thankful for any hint from your side! I already tried posting this
problem to the galax mailing list but didn't get any answer. The activity of
the project seems to be down somehow... There was also no reaction to my bug
report in their bugzilla for about two weeks. Does anyone know about the
status of the project? There has still been an update of galax in February
2007, so someone is still working on it... 

I would also be thankful for the current state of the XQuery update facility
implementations or implementations of some alternative XQuery update

Thanks in advance for your answers!
Vitali Gontsharuk 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://x-query.com/pipermail/talk/attachments/20070608/bfa7bcd0/attachment.htm

More information about the talk mailing list