Specific elements as function input types
Monday, 20 April 2015 · 2 messages
KK
Kristian Kankainen20 Apr 2015 10:48 #
Hello!
I wonder why I get a syntax error in BaseX for the following code. Is it really not possible to specify this fine granularity for function input types?
<code>
declare variable $local:ns := "somenamespace
declare function local:afunction(
$input as element( QName( $local:ns, "elementname" ) )
) {
<function-body />
};
</code>I get error XPST0003 Expecting ')' found '('.
Best regards
Kristian Kankainen
CG
Christian Grün20 Apr 2015 12:01 #
Hi Kristian,
Quoted text · Kristian Kankainen · 3 lines
> I wonder why I get a syntax error in BaseX for the following code. Is it > really not possible to specify this fine granularity for function input > types?
BaseX behaves correctly. This is what you can do instead:
declare namespace ns = "somenamespace";
declare function local:afunction(
$input as element(ns:elementname)
) { ... };...or...
declare function local:afunction(
$input as element(Q{somenamespace}elementname)
) { ... };If you are interested to know why the spec does not support your query, the best place to ask is probably the talk at x-query.com mailing list [1].
Hope this helps,
Christian
[1] http://x-query.com/mailman/listinfo/talk
Quoted text · Kristian Kankainen · 16 lines
> > <code> > declare variable $local:ns := "somenamespace > declare function local:afunction( > $input as element( QName( $local:ns, "elementname" ) ) > ) { > > <function-body /> > > }; > </code> > > I get error XPST0003 Expecting ')' found '('. > > Best regards > Kristian Kankainen
Written for BaseX 8.1. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery