GET/POST params in XQSP?

5 views
Skip to first unread message

Daniel Kvasnicka jr.

unread,
Nov 20, 2008, 4:02:10 AM11/20/08
to xbird-users
Hey,

nice looking project... seems like it could be a good lightweight
alternative to eXist!
I have a few questions regarding XQSP.

-- how do I access GET/POST params? I tried to declare an external
XQuery variable, but xbird tells me it's not set.

-- what functions/what part of XQuery is supported in your XQuery
implementation?

-- is it possible to update XML file from XQSP?

-- is it possible to write my own extension functions in Java and use
them in XQSP?

-- how can I access XML files from XQSP by prviding relative path? I
need to access XML data in WEB-INF, regardles where the app is on the
disk

Keep up the good work!

Makoto YUI

unread,
Nov 20, 2008, 10:40:07 AM11/20/08
to xbird-users
> -- how do I access GET/POST params? I tried to declare an external
> XQuery variable, but xbird tells me it's not set.

Please set a specific URI "xbird://xqsp" for the external variables.
http://code.google.com/p/xbird/source/browse/trunk/xbird-open/main/src/java/xbird/servlet/xqsp/XQueryServlet.java#112

> -- what functions/what part of XQuery is supported in your XQuery
> implementation?

The latest XBird passes 91% of the minimal conformance of XQuery Test
Suite.
Detail of its *previous* results can be found at
http://www.w3.org/XML/Query/test-suite/XQTSReportSimple.html

Proprietary extensions to XQuery functions are implemented in
http://code.google.com/p/xbird/source/browse/trunk/xbird-open/main/src/java/xbird/xquery/func/ext/

> -- is it possible to update XML file from XQSP?

Possible but not supported.

[FYI-1] An example of deleting an existing document from a collection.
http://code.google.com/p/xbird/source/browse/trunk/xbird-open/main/src/java/xbird/ext/xstream/XBirdCollectionStrategy.java#135
[FYI-2] Importing a document from XQST is supported via ext:import-
document function.
http://code.google.com/p/xbird/source/browse/trunk/xbird-open/main/src/java/xbird/xquery/func/ext/DynamicImport.java

> -- is it possible to write my own extension functions in Java and use
> them in XQSP?

Yes. It is easy to create extention functions. Some examples found in
http://code.google.com/p/xbird/source/browse/trunk/xbird-open/main/src/java/xbird/xquery/func/ext/

> -- how can I access XML files from XQSP by prviding relative path? I
> need to access XML data in WEB-INF, regardles where the app is on the
> disk

fn:doc("relative path from xqsp servlet file").

The URI of xqsp servlet file is used to resolve documents in fn:doc().
http://code.google.com/p/xbird/source/browse/trunk/xbird-open/main/src/java/xbird/servlet/xqsp/XQueryServlet.java#155
http://code.google.com/p/xbird/source/browse/trunk/xbird-open/main/src/java/xbird/xquery/func/doc/Doc.java#75

Thanks,
Makoto

Daniel Kvasnicka jr.

unread,
Nov 20, 2008, 3:02:16 PM11/20/08
to xbird-users
Hi Makoto,
thanks for your reply. I still have dome problems, but I'm an xquery
newbie, so forgive me if my questions are a little bit stupid :)

Firs problem is that the servlet freezes very often and I have to kill
the container (tested on Win XP/Java 1.5 and Mac OS X/Java 1.6 with
Tomcat 6). I see that you use some kind of locking in your servlet,
maybe it misbehaves...?

On Nov 20, 4:40 pm, Makoto YUI <yuin...@gmail.com> wrote:
> > -- how do I access GET/POST params? I tried to declare an external
> > XQuery variable, but xbird tells me it's not set.
>
> Please set a specific URI "xbird://xqsp" for the external variables.http://code.google.com/p/xbird/source/browse/trunk/xbird-open/main/sr...

If I write a primitive xquery page like this:

declare namespace req = "xbird://xqsp";
declare variable $req:x external;

$req:x

and call /page.xqp?x=3 I get: xbird.xquery.XQueryException: err:XQ0049
Duplicate global variable: {xbird://xqsp}x
What am I doing wrong?

>
> > -- is it possible to write my own extension functions in Java and use
> > them in XQSP?
>
> Yes. It is easy to create extention functions. Some examples found inhttp://code.google.com/p/xbird/source/browse/trunk/xbird-open/main/sr...

How do I import and use them? JavaFunction class is marked as
deprecated and does not work for me (UnsupportedOperationException)

>
> > -- how can I access XML files from XQSP by prviding relative path? I
> > need to access XML data in WEB-INF, regardles where the app is on the
> > disk
>
> fn:doc("relative path from xqsp servlet file").
>
> The URI of xqsp servlet file is used to resolve documents in fn:doc().http://code.google.com/p/xbird/source/browse/trunk/xbird-open/main/sr...http://code.google.com/p/xbird/source/browse/trunk/xbird-open/main/sr...
>

When I use declare variable $doc := doc("WEB-INF/web.xml");
I get: java.lang.IllegalArgumentException: URI is not absolute. Seems
like the path cannot be relative at all....

Thanks for info,
Dan

Makoto YUI

unread,
Nov 20, 2008, 7:20:58 PM11/20/08
to xbird...@googlegroups.com
XQTS was created 2 year ago for a simple demonstration of XBird.

Unused features (for that time) should be revised for this time.
#I found bugs with your comments. Thanks!

I have to go a seminar today, so I will take a look at
the bugs on this weekend.

Makoto

Makoto YUI

unread,
Nov 20, 2008, 7:25:23 PM11/20/08
to xbird-users
On Nov 21, 9:20 am, "Makoto YUI" <yuin...@gmail.com> wrote:
> XQTS was created 2 year ago for a simple demonstration of XBird.

XQTS -> xqsp ;-)

Makoto YUI

unread,
Nov 22, 2008, 9:54:24 PM11/22/08
to xbird-users
Keep you waiting?

> First problem is that the servlet freezes very often and I have to kill
> the container (tested on Win XP/Java 1.5 and Mac OS X/Java 1.6 with
> Tomcat 6). I see that you use some kind of locking in your servlet,
> maybe it misbehaves...?

A lock was not properly released on failure conditions.
This bug is fixed in the SVN trunk.

There is no problem with my test, running hevy http-load using
JMeter,
on Sun JDK 1.6/Tomcat 6/Windows.

> If I write a primitive xquery page like this:
>
> declare namespace req = "xbird://xqsp";
> declare variable $req:x external;
>
> $req:x
>
> and call /page.xqp?x=3 I get: xbird.xquery.XQueryException: err:XQ0049
> Duplicate global variable: {xbird://xqsp}x
> What am I doing wrong?

You are not wrong. I was wrong :-(
This bug is fixed. Please try the same thing with the latest war file.

> How do I import and use them? JavaFunction class is marked as
> deprecated and does not work for me (UnsupportedOperationException)

JavaFunction class is deprecated and not activated.
You have to implement new class that extends BuiltInFunction, e.g.,
http://code.google.com/p/xbird/source/browse/trunk/xbird-open/main/src/java/xbird/xquery/func/ext/Hostname.java

While little knowledge to XBird internal is required, lots of examples
exist in
http://code.google.com/p/xbird/source/browse/trunk/xbird-open/main/src/java/xbird/xquery/func/

> When I use declare variable $doc := doc("WEB-INF/web.xml");
> I get: java.lang.IllegalArgumentException: URI is not absolute. Seems
> like the path cannot be relative at all....

Fixed.
Please try it again.

Thanks,
Makoto

Daniel Kvasnička jr.

unread,
Nov 23, 2008, 11:51:56 AM11/23/08
to xbird...@googlegroups.com
Hey, thanks for your response and work!

On Sun, Nov 23, 2008 at 3:54 AM, Makoto YUI <yui...@gmail.com> wrote:
>
> Keep you waiting?
>
>> First problem is that the servlet freezes very often and I have to kill
>> the container (tested on Win XP/Java 1.5 and Mac OS X/Java 1.6 with
>> Tomcat 6). I see that you use some kind of locking in your servlet,
>> maybe it misbehaves...?
>
> A lock was not properly released on failure conditions.
> This bug is fixed in the SVN trunk.
>
> There is no problem with my test, running hevy http-load using
> JMeter,
> on Sun JDK 1.6/Tomcat 6/Windows.

Seems like it's ok with me too.

>
>> If I write a primitive xquery page like this:
>>
>> declare namespace req = "xbird://xqsp";
>> declare variable $req:x external;
>>
>> $req:x
>>
>> and call /page.xqp?x=3 I get: xbird.xquery.XQueryException: err:XQ0049
>> Duplicate global variable: {xbird://xqsp}x
>> What am I doing wrong?
>
> You are not wrong. I was wrong :-(
> This bug is fixed. Please try the same thing with the latest war file.

Working!

>
>> How do I import and use them? JavaFunction class is marked as
>> deprecated and does not work for me (UnsupportedOperationException)
>
> JavaFunction class is deprecated and not activated.
> You have to implement new class that extends BuiltInFunction, e.g.,
> http://code.google.com/p/xbird/source/browse/trunk/xbird-open/main/src/java/xbird/xquery/func/ext/Hostname.java
>
> While little knowledge to XBird internal is required, lots of examples
> exist in
> http://code.google.com/p/xbird/source/browse/trunk/xbird-open/main/src/java/xbird/xquery/func/

So I've experimented with this a little, but I still don't know how to
import the func. I placed it in the xbird.xquery.func.ext package and
checked whether XQSP will be able to find it there automatically, but
no luck. Do I have to explicitly define it in my xquery scripts?
I've noticed PredefinedFunction class, but that seems to be completely
write-protected from outside.

>
>> When I use declare variable $doc := doc("WEB-INF/web.xml");
>> I get: java.lang.IllegalArgumentException: URI is not absolute. Seems
>> like the path cannot be relative at all....
>
> Fixed.
> Please try it again.

Works too!

>
> Thanks,
> Makoto

I thank you :)

Daniel

Makoto YUI

unread,
Nov 23, 2008, 2:35:28 PM11/23/08
to xbird-users
> So I've experimented with this a little, but I still don't know how to
> import the func. I placed it in the xbird.xquery.func.ext package and
> checked whether XQSP will be able to find it there automatically, but
> no luck. Do I have to explicitly define it in my xquery scripts?
> I've noticed PredefinedFunction class, but that seems to be completely
> write-protected from outside.

Yeah. Some modifications to PredefinedFunction *were* required.

It was dull, so I made a simple workaround for this issue.

Please follow the following instructions:
1. Make your own FunctionProvider class that implements
xbird.xquery.func.FunctionProvider.
An example is put on http://code.google.com/p/xbird/source/browse/trunk/xbird-open/main/test/java/xbird/xquery/func/
2. Set "xbird.xquery.func.provider=yourpackage.yourFunctionProvider"
in xbird.properties.

Then, your functions will be activated.

Don't forget to use the latest war file.

Makoto

Daniel Kvasnička jr.

unread,
Nov 24, 2008, 1:35:29 PM11/24/08
to xbird...@googlegroups.com
Hey, it works! But I had to study the source to find out that
xbird.properties cannot be wherever I want on the classpath and must
be in xbird/config. Maybe you could change that -- if it's not your
special design decission... ;)

btw: I've done some advertising for you today ;) see the discussion at
http://broadcast.oreilly.com/2008/11/test-driving-marklogic-40-xml.html

Keep up the good work,
Dan

--
http://www.danielkvasnicka.net -- webdesign & corporate design,
programování internetových a intranetových aplikací | webdesign &
corporate design, web applications development

Makoto YUI

unread,
Nov 24, 2008, 8:12:19 PM11/24/08
to xbird-users
On Nov 25, 3:35 am, "Daniel Kvasnička jr."
<daniel.kvasnicka...@gmail.com> wrote:
> Hey, it works! But I had to study the source to find out that
> xbird.properties cannot be wherever I want on the classpath and must
> be in xbird/config. Maybe you could change that -- if it's not your
> special design decission... ;)

xbird.properties is configurable by putting xbird.properties on
System.getProperty("user.dir").
See http://code.google.com/p/xbird/source/browse/trunk/xbird-open/main/src/java/xbird/config/Settings.java

> btw: I've done some advertising for you today ;) see the discussion at http://broadcast.oreilly.com/2008/11/test-driving-marklogic-40-xml.html

Thank you so much. Early adapters are welcome.

Makoto
Reply all
Reply to author
Forward
0 new messages