XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
David LeeSubject: XQuery "declare xmlspace preserve" not working
Author: David Lee
Date: 03 Oct 2006 10:17 AM
Originally Posted: 03 Oct 2006 10:15 AM
I cannot get "preserve whitespace" option working in any processor in XQuery. Various docs I've found (elsewhere) say to add

declare xmlspace = preserve;

or
declare xmlspace preserve;

These both bring up errors in Saxon, DataDirect and Builtin query processors. I cant find any other documentation on how to get this to work. Any suggestions appreciated !

Postnext
(Deleted User) Subject: Re: XQuery "declare xmlspace preserve" not working
Author: (Deleted User)
Date: 03 Oct 2006 10:30 AM
Hi David,
the declaration you are using are coming from older versions of the
XQuery specs; the Candidate Recommendation now specifies

declare boundary-space preserve;

(or "strip")

Hope this helps,
Alberto

Postnext
David LeeSubject: Re: XQuery
Author: David Lee
Date: 03 Oct 2006 10:57 AM
That worked great !

I'm running into this problem all the time, where the documentation (even that on stylusstudio.com) differs from the implementation ...
This was one example. Another is "declare function" instead of what stylus docs say "define function" ... another is using "xsd:anySimpleType" instead of "xs:anySimpleType" ...

Do you have any suggestions on where to look for the actual implemented XQuery standards including the declare and types ?

Thanks for any pointers ...

(Stylus should really update their examples !! most of them dont work due to this issue)

Postnext
(Deleted User) Subject: Re: XQuery
Author: (Deleted User)
Date: 03 Oct 2006 01:09 PM
Hi, David. Thanks for pointing out the oversight with "define function" statement. I've updated the doc and it will be available with the next Stylus Studio update release.

Can you tell me where you found a use of xsd:anySimpleType? I've searched our doc and have come up empty.

Thanks for your help.

David Foster
Stylus Studio Team

Postnext
David LeeSubject: Re: XQuery
Author: David Lee
Date: 03 Oct 2006 01:17 PM
I found xs:anySimpleType in the recommended book "XQuery from the experts" . I tried it using both Saxon and Builtin processors and the code-complete wizard completes it fine, but the I get compile errors.
Looking on the net I found an example using "xsd:anySimpleType"
http://xsd.stylusstudio.com/2002Dec/post00001.htm

which I also get compiler errors for ...

I was able to get xdt:anyAtomicType to work (again a massive guess from browsing around).

My main issue is that I would love to see a single reference as to syntax, functions, and types supported by XQuery ... I know some of this is beyond your control ... say using saxon, that would be saxon's implementation ... but saxon seems to be doing very similar to "BuiltIn" and I simply cannot find docs anywhere that have a simple comprehensive listing of

* language statments / keywords
* global or imported types
* global or imported functions




Postnext
(Deleted User) Subject: Re: XQuery
Author: (Deleted User)
Date: 03 Oct 2006 03:14 PM
Hi David,
anySimpleType is a type defined in the XMLSchema namespace, so you
can use whatever prefix has been associated to that namespace (XQuery
automatically associate "xs" with that namespace, so xs:anySimpleType
is always correct).
So I guess the error you were getting was caused by the context in
which the type was used; can you post the query so that we can
understand the real error?

As for anyAtomicType, it was initially defined in a XQuery-specific
namespace that was automatically associated with the "xdt" prefix;
however, in the latest version of the specs it has been decided to
move it to the XMLSchema namespace, so now you could also use
xs:anyAtomicType (in order to help users, several XQuery
implementation decided to keep defining the "xdt" prefix, making it
an alias for "xs").

Coming to your final question, the underlying problem is that the
XQuery specs have not yet reached the Recommendation status, so all
the material published until now has been based on Working Draft
documents; for example, the "XQuery from the experts" book is aligned
with the May 2003 release.

The good news is that the XQuery specs have now reached the Candidate
Recommendation phase, and that means that there will be no more
changes in the syntax; both Saxon and the built-in processor
implement this version, so you directly use the official W3C
documents to learn the syntax.

XQuery 1.0 language: http://www.w3.org/TR/xquery/
XPath 2.0/XQuery 1.0 functions: http://www.w3.org/TR/xpath-functions/

Hope this helps,
Alberto

Postnext
David LeeSubject: Re: XQuery
Author: David Lee
Date: 03 Oct 2006 03:34 PM
Here's the example from the book I was trying to test.

declare function local:ts3( $x as xsd:anySimpleType ) as element()
{
typeswitch( $x )
case $i as xs:integer return <foo>{$i}</foo>
default return error(xs:QName("Error"))
};

(book used "define" but I figured that out)

This fails compilation with
"Type {http://www.w3.org/2001/XMLSchema}:anySimpleType is not an atomic type [err:XPST0051].
Using "BuiltIn" processor

and fails with Saxon with

"XQuery static error on @...:ts3( $x as xs:anySimpleType)#: Unknown atomic type xs:anySimpleType"

I had also tried this which I found on the net as an example. ...
declare function local:ts( $x as xsd:anyAtomicType ) as element()

which also fails


Whereas this works:

declare function local:ts( $x as xdt:anyAtomicType ) as element()

...
Lucky guess ... :)



As for XQuery language Status, I realize its an ever evolving thing and I can handle that fact that its changing. Whats frustrating me is thing to figure out what "this seconds snapshot" looks like !
I've been having about a 10% success rate finding docs and examples that actually work (across the net ...).

I realize that I'm somewhat complaining to the wrong team ... e.g. Stlyus didnt write saxon ... but so lets focus on just "BuiltIn" or "XQueryDirect" ... I cant find the syntax definitions anywhere what the current version in the software I just bought last week ... That's frustrating... Especially when vague references to "see the XQuery standards blah blah blah" all pull up examples and specs that don't actually quite work .... because they document last weeks standard not today's ... Perhaps I'm not looking in the right place ... but I've looked pretty hard ...

So again, I'm suggesting that maybe Stylus, as a provider of a GREAT XQuery tool (best I've found yet) maybe publish a simple 1 page matrix with all the reserved words, declare tags, function names and maybe a big "X" mark in each column for each supported XQuery Processor ...
Or baring that, maybe a separate page for each supported processor indicating the conformance to a particular standard, or even just a list of the supported keywords, functions and types that are actually implemented (compliant or not with standards).

Maybe such a thing exists somewhere ??? That would be a lifesaver, as it is I'm in constant "hunt and peck" mode ... try this try that try something else ... feeling like a total idiot because I can find no documentation of what the actual implementation is accepting except by trial & error ... mostly error :(



-David

Postnext
(Deleted User) Subject: Re: XQuery
Author: (Deleted User)
Date: 04 Oct 2006 08:24 AM
Hi David,
the expression $x as xs:anySimpleType is no more a legal one, as the
name of the type must be an atomic type (i.e. derived from
xs:anyAtomicType) and xs:anyAtomicType derives from xs:anySimpleType.

I tried this query

declare function local:ts3( $x as xs:anyAtomicType ) as element()
{
typeswitch( $x )
case $i as xs:integer return <foo>{$i}</foo>
default return error(xs:QName("Error"))
};
local:ts3(1)

and it worked; as you are using the "xsd" prefix (that is not one of
the predefined ones) have you added the

declare namespace xsd = "http://www.w3.org/2001/XMLSchema";

declaration to the prolog?
Remember that you can always use the "xs" prefix without declaring.

Coming to your last question, the XQuery specs have a section on
conformance that in essence says "all processors must implement the
'minimal conformance' subset of the language and list what optional
features are supported".
You can see at http://www.w3.org/XML/Query/test-suite/XQTSReport.html
which part of the specs each processor implements; but up to now, no
vendor has produced a documentation for the language itself, as they
rely on the official language document published at
http://www.w3.org/TR/xquery/
You can also read the use cases published at
http://www.w3.org/TR/xquery-use-cases/; they are guaranteed to be
using the latest keywords.

Hope this helps,
Alberto

Postnext
David LeeSubject: Re: XQuery
Author: David Lee
Date: 04 Oct 2006 09:04 AM
Thanks ! That Use Case link is golden. Exactly what I've been looking for. Very much appreciated.

I really cant wait until the XQuery languages stabilizes so that these problems go away ... ( the problem being that of me trying to figure out what the language is exactly, and use it property; not a problem with the language itself)

Maybe I'll see you at the XML2006 conference in Boston ?

-David Lee

Posttop
(Deleted User) Subject: Re: XQuery
Author: (Deleted User)
Date: 04 Oct 2006 11:37 AM
Hi David,
I think XQuery is ready to move from being an abstract language to
become a useful tool for XML applications.

A clear indication of this is the fact that XML2006 will not have the
usual "What is XQuery" session, but a full day tutorial; and there
will be a bunch of sessions like "Applying XQuery to ..." (see "An
XQuery Servlet for RESTful Data Services" by Jonathan Robie,
http://2006.xmlconference.org/programme/presentations/87.html)

See you there!

Alberto

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.