Versionning proposal

6 views
Skip to first unread message

mozer

unread,
Apr 17, 2009, 2:47:51 PM4/17/09
to exp...@googlegroups.com
versioning proposal


"http://expath.org/ns/core"
"http://expath.org/ns/<module>"

we need a function

core:function-available(AnyURI namespace, String name) as boolean
core:function-available(AnyURI namespace, String name, int arity) as boolean
core:function-available(QName function) as boolean
core:function-available(QName function, int arity) as boolean


Extending
We can add (because we have function-available())
* new name function (as soon as it make sens in the current package)
* same name function with different arity than existing one

We can create new package

We can deprecate existing function in a package trough documentation

If we want to refactor completly we have the following choices

Having a major new branch

"http://v2.expath.org/ns/core"

or local branching

"http://expath.org/ns/core/v2"

or new module

"http://expath.org/ns/xcore"

Xmlizer

David Carlisle

unread,
Apr 17, 2009, 3:57:52 PM4/17/09
to exp...@googlegroups.com


2009/4/17 mozer <xml...@gmail.com>


we need a function

core:function-available(AnyURI namespace, String name) as boolean
core:function-available(AnyURI namespace, String name, int arity) as boolean
core:function-available(QName function) as boolean
core:function-available(QName function, int arity) as boolean


Yes, I think we need these. But actually function-available() isn't as easily usable in xpath2 as it was xpath1
as  if(core:function-available(QName('math:sin')) then math:sin($x) else $x is likely to give a compile time error
on the math:sin($x) even if function-available would return false when run.

I'm not sure if it's possible to devise an expath (or exquery) pragma syntax that works something like use-when in xslt and allows compile time guarding of expressions that might not be portable?

David

--
http://dpcarlisle.blogspot.com/

Florent Georges

unread,
Apr 17, 2009, 4:20:03 PM4/17/09
to exp...@googlegroups.com
2009/4/17 mozer wrote:

Hi,

> versioning proposal

Yes, I agree with that, providing as you said that a module can
introduce a version number if absolutely necessary. I am not sure the
"core" ns should be treated specially, but who knows?

> core:function-available(AnyURI namespace, String name) as boolean
> core:function-available(AnyURI namespace, String name, int arity) as boolean
> core:function-available(QName function) as boolean
> core:function-available(QName function, int arity) as boolean

I think xs:string would be better than xs:anyURI (for the same
reasons F&O functions takes strings for URIs.)

> Extending
> We can add (because we have function-available())
> * new name function (as soon as it make sens in the current package)
> * same name function with different arity than existing one

Those cases do not really need function-available() for versioning
purpose. If the implementation does not support them, there would be
a compilation error.

But if one has an alternative, as David said, it would maybe be
interesting for her to be able to detect it at compile-time. But I am
not sure how we could handle that in an elegant way. If we backport
XQuery pragmas, we'll generate compile-errors if the implementation
does not support them, and if we use something like (:# ... #:) we
could generate compile-time errors for legitimate XPath comments, or
not reach our goals if the implementation does not recognize it.

I wonder if this is not the responsibility of the host language to
ensure the existence of the function (name or arity,) and to take
adequate behavior if not (use-when in XSLT, pragma in XQuery, or a
separate call to function-available() if, say, in Java.)

So about namespace URIs: +1. About function-available(): +1. About
preventing compile-time errors for unsupported functions: yes, but
how?

Regards,

--
Florent Georges
http://www.fgeorges.org/

Kurt Cagle

unread,
Apr 17, 2009, 8:24:19 PM4/17/09
to exp...@googlegroups.com
I think function-available() plays a bigger role if there is some type of util:eval() or util:load-module() capability.

Kurt Cagle
Managing Editor
http://xmlToday.org

Martin Probst

unread,
Apr 18, 2009, 5:41:34 AM4/18/09
to exp...@googlegroups.com
>> So about namespace URIs: +1. About function-available(): +1. About
>> preventing compile-time errors for unsupported functions: yes, but
>> how?
>
> I think function-available() plays a bigger role if there is some type of
> util:eval() or util:load-module() capability.

I think that will not quite be possible in XQuery. The spec says it's
a static, compile time error if a function is not available. E.g. in
case we have a newer http-get function that supports an additional
cookie parameter, this would not work:

if (function-available("http://expath.org/ns/core", "http-get", 2)) then
expath:http-get('http://www.example.com', $mycookie)
else
expath:http-get('http://www.example.com')

It might somehow work if we have higher order functions, and they
support dynamically instantiating functions:

let $http-call as function() :=
if (function-available("http://expath.org/ns/core", "http-get", 2)) then
get-function('expath:http-get#2')
else
get-function('expath:http-get#1')
return ...

... but with plain XQuery as it is now, such a dynamic fall back is
impossible. Maybe this would make a good case for a first extension
function.

Martin

Florent Georges

unread,
Apr 18, 2009, 7:31:09 AM4/18/09
to EXPath
On Apr 18, 11:41 am, Martin Probst wrote:

> >>  So about namespace URIs: +1.  About function-available(): +1.  About
> >> preventing compile-time errors for unsupported functions: yes, but
> >> how?

> > I think function-available() plays a bigger role if there is some type of
> > util:eval() or util:load-module() capability.

> I think that will not quite be possible in XQuery. The spec says it's
> a static, compile time error if a function is not available.

Yes, I think that's Kurt's point: this function would be
particularly useful with a dynamic evaluation function:

if ( util:function-available("http:send-request", 1) ) then
util:eval("http:send-request(...)")
else
...

Martin Probst

unread,
Apr 18, 2009, 7:54:59 AM4/18/09
to exp...@googlegroups.com
>    if ( util:function-available("http:send-request", 1) ) then
>      util:eval("http:send-request(...)")

Or rather util:eval($namespace, $functionname, $args...)?

Martin

Florent Georges

unread,
Apr 18, 2009, 7:59:15 AM4/18/09
to EXPath
I am note sure to understand; a dynamic evaluation function would be
able to evaluate any XPath expression: util:eval("1 + 2").

Martin Probst

unread,
Apr 18, 2009, 8:02:59 AM4/18/09
to exp...@googlegroups.com
>> >    if ( util:function-available("http:send-request", 1) ) then
>> >      util:eval("http:send-request(...)")
>
>> Or rather util:eval($namespace, $functionname, $args...)?
>
>  I am note sure to understand; a dynamic evaluation function would be
> able to evaluate any XPath expression: util:eval("1 + 2").

Eh yes, I'd just rather see a dynamic function invocation function.
That seems less invasive, and we all know eval is evil.

util:invoke($namespace, $functionname, $args...)

That way you don't have to take care you get the syntax right, you
don't have to invoke a parser, and so on.

Martin

James Fuller

unread,
Apr 18, 2009, 8:38:57 AM4/18/09
to exp...@googlegroups.com


2009/4/18 Martin Probst <ma...@martin-probst.com>


>> >    if ( util:function-available("http:send-request", 1) ) then
>> >      util:eval("http:send-request(...)")
>
>> Or rather util:eval($namespace, $functionname, $args...)?
>
>  I am note sure to understand; a dynamic evaluation function would be
> able to evaluate any XPath expression: util:eval("1 + 2").

Eh yes, I'd just rather see a dynamic function invocation function.
That seems less invasive, and we all know eval is evil.

 util:invoke($namespace, $functionname, $args...)

util:invoke(....) or util:eval(...) would work off the default context ... we might also want to consider having an overloaded version be able to pass in context e,g, serialization params, pragmas, etc ....we may even want to pass in a default context or named variables instead of doing $somevar/util:invoke(...)

cheers, Jim Fuller

 
we might also want to consider an overloaded version to arbitrarily pass in default context as well
 

Adam Retter

unread,
Apr 18, 2009, 1:19:55 PM4/18/09
to exp...@googlegroups.com
> Eh yes, I'd just rather see a dynamic function invocation function.
> That seems less invasive, and we all know eval is evil.
>
>  util:invoke($namespace, $functionname, $args...)
>
> That way you don't have to take care you get the syntax right, you
> don't have to invoke a parser, and so on.


Blowing the eXist trumpet for a second (sorry), we have something
similar already -

util:function() and util:call()

util:call(util:function(xs:QName("http:send-request"), 1), $args)

Documentation is available here -
http://demo.exist-db.org/exist/xquery/functions.xql


--
Adam Retter

EXQuery Founder
t: +44 (0)7714 330069
e: adam....@exquery.org
w: www.exquery.org

Kurt Cagle

unread,
Apr 18, 2009, 2:51:43 PM4/18/09
to exp...@googlegroups.com
Adam,

I think the entire eXist util: namespace is worth some serious consideration here (of course that could be said for a lot of extensions in eXist, but that one in particular is just chock full of goodness). For those that don't have an implementation handy here's what's supported:

binary-doc

util:binary-doc($a as xs:string?) xs:base64Binary?
Retrieves the binary resource identified by $a and returns its contents as a value of type xs:base64Binary. An empty sequence is returned if the resource could not be found or $a was empty.

binary-doc-available

util:binary-doc-available($a as xs:string?) xs:boolean
Checks if the binary resource identified by $a is available.

binary-to-string

util:binary-to-string($a as xs:base64Binary?) xs:string?
Returns the contents of a binary resource as an xs:string value. The binary data is transformed into a Java string using the encoding specified in the optional second argument or UTF-8.

binary-to-string

util:binary-to-string($a as xs:base64Binary?, $b as xs:string) xs:string?
Returns the contents of a binary resource as an xs:string value. The binary data is transformed into a Java string using the encoding specified in the optional second argument or UTF-8.

call

util:call($a as function, $b as item()*, ...) item()*
Invokes a first-class function reference created by util:function. The function to be called is passed as the first argument. All remaining arguments are forwarded to the called function.

catch

util:catch($a as xs:string+, $b as item()*, $c as item()*) item()*
This function corresponds to a try-catch statement in Java. The code block in $b will be put inside a try-catch statement. If an exception is thrown while executing $b, the function checks the name of the exception and calls $c if it matches one of the fully qualified Java class names specified in $a. A value of "*" in $a will catch all java exceptions

collations

util:collations() xs:string*
Returns a sequence of strings containing all collation locales that might be specified in the '?lang=' parameter of a collation URI.

collection-name

util:collection-name($a as item()?) xs:string?
Returns the name of the collection from a passed node or path string. If the argument is a node, the function returns the name of the collection to which the node's document belongs. If the argument is a string, it is interpreted as path to a resource and the function returns the computed parent collection path for this resource.

compile

util:compile($a as xs:string) xs:string
Dynamically evaluates the XPath/XQuery expression specified in $a within the current instance of the query engine.

declare-namespace

util:declare-namespace($a as xs:string, $b as xs:anyURI) empty()
Dynamically declares a namespace/prefix mapping for the current context. The prefix is specified in $a, the namespace URI in $b.

declare-option

util:declare-option($a as xs:string, $b as xs:string) empty()
Dynamically declares a serialization option as with 'declare option'.

deep-copy

util:deep-copy($a as item()?) item()?
Performs a Deep Clone of the Parameter $a

describe-function

util:describe-function($a as xs:QName) node()
Describes a built-in function. Returns an element describing the function signature.

disable-profiling

util:disable-profiling() empty()
Disable profiling output within the query.

doctype

util:doctype($a as xs:string+, ...) node()*
Returns the document nodes of the documents whose DOCTYPE is given by $a.

document-id

util:document-id($a as item()) xs:int?
Returns the internal integer id of a document. The argument can either be a node or a string path pointing to a resource in the database. If the resource does not exist or the node does not belong to a stored document, the empty sequence is returned.

document-name

util:document-name($a as item()) xs:string?
Returns the name of a document (excluding the collection path). The argument can either be a node or a string path pointing to a resource in the database. If the resource does not exist or the node does not belong to a stored document, the empty sequence is returned.

eXist-version

util:eXist-version() xs:string
Returns the version of eXist running this query.

enable-profiling

util:enable-profiling($a as xs:int) empty()
Enable profiling output within the query. The profiling starts with this function call and will end with a call to 'disable-profiling'. Argument $a specifies the verbosity. All other profiling options can be configured via the 'declare option exist:profiling ...' in the query prolog.

eval

util:eval($a as item()) node()*
Dynamically evaluates an XPath/XQuery expression. If the first argument is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed.

eval

util:eval($a as item(), $b as xs:boolean) node()*
Dynamically evaluates an XPath/XQuery expression. If the first argument is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the current execution context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed. The third argument specifies if the compiled query expression should be cached. The cached query will be globally available within the db instance.

eval-inline

util:eval-inline($a as item()*, $b as item()) item()*
Dynamically evaluates an XPath/XQuery expression. If the first argument is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the first argument's context, i.e. all namespace declarations and variable declarations are visible from within the inner expression. The function returns an empty sequence if a whitespace string is passed.

eval-with-context

util:eval-with-context($a as item(), $b as node()?, $c as xs:boolean) node()*
Dynamically evaluates an XPath/XQuery expression. If the first argument is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the context described by the XML fragment in the second parameter. It should have the format: <static-context> <output-size-limit value="-1"> <unbind-namespace uri="http://exist.sourceforge.net/NS/exist"/> <current-dateTime value="dateTime"/> <implicit-timezone value="duration"/> <variable name="qname">variable value</variable> <mapModule namespace="uri" uri="uri_to_module"/> </static-context>. The third argument specifies if the compiled query expression should be cached. The cached query will be globally available within the db instance.

eval-with-context

util:eval-with-context($a as item(), $b as node()?, $c as xs:boolean, $d as item()?) node()*
Dynamically evaluates an XPath/XQuery expression. If the first argument is of type xs:string, the function tries to execute this string as the query. If the first argument is of type xs:anyURI, the function will try to load the query from the resource to which the URI resolves. If the URI has no scheme, it is assumed that the query is stored in the db and the URI is interpreted as a database path. This is the same as calling util:eval(xs:anyURI('xmldb:exist:///db/test/test.xq')). The query inherits the context described by the XML fragment in the second parameter. It should have the format: <static-context> <output-size-limit value="-1"> <unbind-namespace uri="http://exist.sourceforge.net/NS/exist"/> <current-dateTime value="dateTime"/> <implicit-timezone value="duration"/> <variable name="qname">variable value</variable> </static-context>. The third argument specifies if the compiled query expression should be cached. The cached query will be globally available within the db instance.The fourth argument specifies the context item against which the expression will be evaluated.

exclusive-lock

util:exclusive-lock($a as node()*, $b as item()*) item()*
Puts an exclusive lock on the owner documents of all nodes in the first argument $a. Then evaluates the expressions in the second argument $b and releases the acquired locks aftertheir completion.

expand

util:expand($a as node()*, $b as xs:string) node()*
Creates an in-memory copy of the passed node set, using the specified serialization options. By default, full-text match terms will be tagged with &lt;exist:match&gt; and XIncludes will be expanded. Serialization parameters can be set in the second argument, which accepts the same parameters as the exist:serialize option.

expand

util:expand($a as node()*) node()*
Creates an in-memory copy of the passed node set, using the specified serialization options. By default, full-text match terms will be tagged with &lt;exist:match&gt; and XIncludes will be expanded.

extract-docs

util:extract-docs($a as xs:string) node()?
Returns an XML document which describes the functions available in a given module. The module is identified through its module namespace URI, which is passed as an argument. The function returns a module documentation in XQDoc format.

file-read

util:file-read($a as item()) xs:string?
Read content of file $a. DEPRECATED: Moved to the file extension module. See file:read()

file-read

util:file-read($a as item(), $b as xs:string) xs:string?
Read content of file $a with the encoding specified in $b. DEPRECATED: Moved to the file extension module. See file:read()

function

util:function($a as xs:QName, $b as xs:integer) function
Creates a reference to an XQuery function which can later be called from util:call. This allows for higher-order functions to be implemented in XQuery. A higher-order function is a function that takes another function as argument. The first argument represents the name of the function, which should bea valid QName. The second argument is the arity of the function. If nofunction can be found that matches the name and arity, an error is thrown. Please note: due to the special character of util:function, the arguments to this function have to be literals or need to be resolvable at compile time at least.

get-fragment-between

util:get-fragment-between($a as node()?, $b as node()?, $c as xs:boolean?) xs:string
A function which delivers the xml fragment between two elements (normally milestone elements)The first argument represents the first node/milestone element, the second argument the secondnode/milestone element between which the fragment should be determined. The third argument is a boolean value for the path completion. If the third argument is set to true() open and closing tags before and after the two nodes/milestones are appended. Example call of the function for getting the fragment between two page breaks: let $fragment := util:get-fragment-between(//pb[1], //pb[2], true())

get-module-description

util:get-module-description($a as xs:string) xs:string
Returns a short description of the module identified by the namespace URI.

get-sequence-type

util:get-sequence-type($a as xs:anyType*) xs:string
Returns the string representation of the type of sequence $a.

hash

util:hash($a as item(), $b as xs:string, $c as xs:boolean) xs:string
Calculate an hashcode from string $a using alghorithm $b. $c specifies whether to return result Base64 encoded

hash

util:hash($a as item(), $b as xs:string) xs:string
Calculate an hashcode from string $a using alghorithm $b.

import-module

util:import-module($a as xs:anyURI, $b as xs:string, $c as xs:anyURI) empty()
Dynamically imports an XQuery module into the current context. The namespace URI of the module is specified in argument $a, $b is the prefix that will be assigned to that namespace, $c is the location of the module. The parameters have the same meaning as in an 'import module ...' expression in the query prolog.

index-key-documents

util:index-key-documents($a as node()*, $b as xdt:anyAtomicType) xs:integer?
Return the number of documents for an indexed value. The first argument specifies the nodes whose content is indexed. The second argument specifies the value.

index-key-documents

util:index-key-documents($a as node()*, $b as xdt:anyAtomicType, $c as xs:string) xs:integer?
Return the number of documents for an indexed value. The first argument specifies the nodes whose content is indexed. The second argument specifies the value. The third argument specifies the index in which the search is made

index-key-occurrences

util:index-key-occurrences($a as node()*, $b as xdt:anyAtomicType) xs:integer?
Return the number of occurrences for an indexed value. The first argument specifies the nodes whose content is indexed. The second argument specifies the value.

index-key-occurrences

util:index-key-occurrences($a as node()*, $b as xdt:anyAtomicType, $c as xs:string) xs:integer?
Return the number of occurrences for an indexed value. The first argument specifies the nodes whose content is indexed. The second argument specifies the value. The third argument specifies the index in which the search is made

index-keys

util:index-keys($a as node()*, $b as xdt:anyAtomicType, $c as function, $d as xs:int) item()*
Can be used to query existing range indexes defined on a set of nodes. All index keys defined for the given node set are reported to a callback function. The function will check for indexes defined on path as well as indexes defined by QName. The node set is specified in the first argument. The second argument specifies a start value. Only index keys of the same type but being greater than $b will be reported for non-stringtypes. For string types, only keys starting with the given prefix are reported. The third arguments is a function reference as created by the util:function function. It can be an arbitrary user-defined function, but it should take exactly 2 arguments: 1) the current index key as found in the range index as an atomic value, 2) a sequence containing three int values: a) the overall frequency of the key within the node set, b) the number of distinct documents in the node set the key occurs in, c) the current position of the key in the whole list of keys returned. The fourth argument is the maximum number of returned keys

index-keys

util:index-keys($a as node()*, $b as xdt:anyAtomicType, $c as function, $d as xs:int, $e as xs:string) item()*
Can be used to query existing range indexes defined on a set of nodes. All index keys defined for the given node set are reported to a callback function. The function will check for indexes defined on path as well as indexes defined by QName. The node set is specified in the first argument. The second argument specifies a start value. Only index keys of the same type but being greater than $b will be reported for non-stringtypes. For string types, only keys starting with the given prefix are reported. The third arguments is a function reference as created by the util:function function. It can be an arbitrary user-defined function, but it should take exactly 2 arguments: 1) the current index key as found in the range index as an atomic value, 2) a sequence containing three int values: a) the overall frequency of the key within the node set, b) the number of distinct documents in the node set the key occurs in, c) the current position of the key in the whole list of keys returned. The fourth argument is the maximum number of returned keysThe fifth argument specifies the index in which the search is made

index-type

util:index-type($a as node()*) xs:string?
Returns the range index type for a set of nodes or an empty sequence if no index is defined.

is-module-registered

util:is-module-registered($a as xs:string) xs:boolean
Returns a Boolean value if the module identified by the namespace URI is registered.

log

util:log($a as xs:string, $b as item()*) empty()
Logs the message specified in $b to the current logger. $a indicates the log priority, e.g. 'debug' or 'warn'.

log-app

util:log-app($a as xs:string, $b as xs:string, $c as item()*) empty()
Logs the message specified in $c to the logger named in $b. $a indicates the log priority, e.g. 'debug' or 'warn'. $b specifies the name of the logger, eg: my.app.log

log-system-err

util:log-system-err($a as item()*) empty()
Logs the message specified in $b to System.err.

log-system-out

util:log-system-out($a as item()*) empty()
Logs the message specified in $b to System.out.

md5

util:md5($a as item()) xs:string
Generates an MD5 key from a string.

md5

util:md5($a as item(), $b as xs:boolean) xs:string
Generates an MD5 key from a string. $b specifies whether to return result Base64 encoded

node-by-id

util:node-by-id($a as node(), $b as xs:string) node()
Retrieves a node by its internal node-id. The document is specified via the first argument. It may either be a document node or another node from the same document from which the target node will be retrieved by its id. The second argument is the internal node-id, specified as a string. Please note: the function does not check if the passed id does really point to an existing node. It just returns a pointer, which may thus be invalid.

node-id

util:node-id($a as node()) xs:string
Returns the internal node-id of a node. The internal node-id uniquely identifies a node within its document. It is encoded as a long number.

node-xpath

util:node-xpath($a as node()) xs:string?
Returns the XPath for a Node.

parse

util:parse($a as xs:string?) node()*
Parses the passed string value into an XML fragment. The string has to be well-formed XML. An empty sequence is returned if the argument is an empty string or sequence.

parse-html

util:parse-html($a as xs:string?) node()*
Parses the passed string value into an XML fragment. The HTML string may not be well-formed XML. It will be passed through the Neko HTML parser to make it well-formed. An empty sequence is returned if the argument is an empty string or sequence.

qname-index-lookup

util:qname-index-lookup($a as xs:QName, $b as xdt:anyAtomicType) node()*
Can be used to query existing qname indexes defined on a set of nodes. The qname is specified in the first argument. The second argument specifies a comparison value.

random

util:random() xs:double
Returns a random number between 0.0 and 1.0

random

util:random($a as xs:integer) xs:integer
Returns a random number between 0 and $a

registered-functions

util:registered-functions() xs:string+
Returns a sequence containing the QNames of all functions currently known to the system, including functions in imported and built-in modules.

registered-functions

util:registered-functions($a as xs:string) xs:string+
Returns a sequence containing the QNames of all functions declared in the module identified by the specified namespace URI. An error is raised if no module is found for the specified URI.

registered-modules

util:registered-modules() xs:string+
Returns a sequence containing the namespace URIs of all modules currently known to the system, including built in and imported modules.

serialize

util:serialize($a as node()*, $b as xs:string*) xs:string?
Returns the Serialized node set passed in parameter $a. $b contains a sequence of zero or more serialization parameters specified as key=value pairs. The serialization options are the same as those recognized by "declare option exist:serialize". The function does NOT automatically inherit the serialization options of the XQuery it is called from.

serialize

util:serialize($a as node()*, $b as xs:string, $c as xs:string*) xs:boolean?
DEPRECATED. Use the file:serialize() function in the file extension module instead! Writes the node set passed in parameter $a into a file on the file system. The full path to the file is specified in parameter $b. $c contains a sequence of zero or more serialization parameters specified as key=value pairs. The serialization options are the same as those recognized by "declare option exist:serialize". The function does NOT automatically inherit the serialization options of the XQuery it is called from. False is returned if the specified file can not be created or is not writable, true on success. The empty sequence is returned if the argument sequence is empty.

shared-lock

util:shared-lock($a as node()*, $b as item()*) item()*
Puts a shared lock on the owner documents of all nodes in the first argument $a. Then evaluates the expressions in the second argument $b and releases the acquired locks aftertheir completion.

string-to-binary

util:string-to-binary($a as xs:string?) xs:base64Binary?
Returns the contents of a binary resource as an xs:string value. The binary data is transformed into a Java string using the encoding specified in the optional second argument or UTF-8.

string-to-binary

util:string-to-binary($a as xs:string?, $b as xs:string) xs:base64Binary?
Returns the contents of a binary resource as an xs:string value. The binary data is transformed into a Java string using the encoding specified in the optional second argument or UTF-8.

system-property

util:system-property($a as xs:string) xs:string?
Returns the value of a system property. Similar to the corresponding XSLT function. Predefined properties are: vendor, vendor-url, product-name, product-version, product-build, and all Java system properties.

system-time

util:system-time() xs:time
Returns the xs:time (with timezone) as reported by the Java method System.currentTimeMillis(). Contrary to fn:current-time, this function is not stable, i.e. the returned xs:time will change during the evaluation time of a query and can be used to measure time differences.

unescape-uri

util:unescape-uri($a as xs:string, $b as xs:string) xs:string
Returns an un-escaped URL escaped string identified by $a with the encoding scheme indicated by the string $b (e.g. "UTF-8"). Decodes encoded sensitive characters from a URL, for example "%2F" becomes "/", i.e. does the oposite to escape-uri()

uuid

util:uuid() xs:string

I find that a significant amount of the code that I need for XQuery app development comes from util:


Kurt Cagle
Managing Editor
http://xmlToday.org


Florent Georges

unread,
Apr 18, 2009, 3:38:20 PM4/18/09
to EXPath
On Apr 18, 2:02 pm, Martin Probst wrote:

> > I am note sure to understand; a dynamic evaluation function
> > would be able to evaluate any XPath expression: util:eval("1
> > + 2").

> Eh yes, I'd just rather see a dynamic function invocation
> function. That seems less invasive, and we all know eval is
> evil.

> util:invoke($namespace, $functionname, $args...)

I was going to say I didn't see the point of such a function,
the behavior of which could be provided by a general purpose
util:eval() function or by first-class function objects. But
actually, I guess that could be useful for that exact issue of
detecting at runtime if a function is supported, without
requiring the whole machinery for full evaluation or first-class
object functions.

Could someone comment on that?

Florent Georges

unread,
Apr 18, 2009, 3:44:24 PM4/18/09
to EXPath
On Apr 18, 2:38 pm, James Fuller wrote:

> util:invoke(....) or util:eval(...) would work off the default context ...
> we might also want to consider having an overloaded version be able to pass
> in context e,g, serialization params, pragmas, etc ....we may even want to
> pass in a default context or named variables instead of doing
> $somevar/util:invoke(...)

Of course. I think the main difficulty (if not the only one) is to
define the interaction between eval() and the XPath context.

For invoke(), that less obvious to me. This just provide an
alternative way to write a function call (util:invoke('my:name', $ar1,
$arg2) instead of my:name($ar1, $arg2)) so I think everything should
be the same between both, except that the first one won't generate a
compile time error, but rather a runtime error.

Did I misunderstood something?

Florent Georges

unread,
Apr 18, 2009, 3:52:01 PM4/18/09
to EXPath
On Apr 18, 7:19 pm, Adam Retter wrote:

> > Eh yes, I'd just rather see a dynamic function invocation function.
> > That seems less invasive, and we all know eval is evil.

> >  util:invoke($namespace, $functionname, $args...)

> Blowing the eXist trumpet for a second (sorry), we have something
> similar already -

> util:function() and util:call()

> util:call(util:function(xs:QName("http:send-request"), 1), $args)

If I am right, this is more than just invoke(): that's a whole first-
class function object system. I wonder after all if this is really
more work than just invoke(). If not, I guess there's no point to
invoke(). For first-class function objects, I guess the best approach
would be to take John Snelson's "Higher Order Functions for XQuery"
<http://snelson.org.uk/~jpcs/higher-order-functions.html> as a basis,
but defining functions instead of grammar changes.

That's definitely something that would be very beneficial for the
community, I think.

Dimitre Novatchev

unread,
Apr 18, 2009, 3:53:09 PM4/18/09
to exp...@googlegroups.com
Florent,

It will be an overkill to implement dynamic evaluation just for the
purpose of making function-available() possible.

One could think of less grandiose mechanisms, such as "deferred
evaluation" or "suppressed static typechecking".

If static type checking could be suppressed (and this would be a nice
meta-function of EXPath), and there was a "try... catch..."
capability, one could write something like ( excuse my ignorance of
XQuery syntactic rules :) )

$foo-available =
suppress-static-typechecking
{
try
{ (: simple invocation of foo :) foo(); return true;}
catch
{return false;}
}


--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play

Florent Georges

unread,
Apr 18, 2009, 3:55:20 PM4/18/09
to EXPath
On Apr 18, 8:51 pm, Kurt Cagle wrote:

> I think the entire eXist util: namespace is worth some serious consideration
> here (of course that could be said for a lot of extensions in eXist, but
> that one in particular is just chock full of goodness). For those that don't
> have an implementation handy here's what's supported:

Thanks for the ref. For those how want to read this doc within
the eXist function documentation system, they can go to
http://demo.exist-db.org/exist/xquery/functions.xql, choose in
the list "Or display all in: http://exist-db.org/xquery/util,"
then click "Browse."

Dimitre Novatchev

unread,
Apr 18, 2009, 3:56:26 PM4/18/09
to exp...@googlegroups.com
For first-class function objects, I guess the best approach
> would be to take John Snelson's "Higher Order Functions for XQuery"
> <http://snelson.org.uk/~jpcs/higher-order-functions.html> as a basis

I read well this document and have definite reservations. Also, it
seems that HOF will be present in the next version of XQuery, so it
would not be useful to create another, competing HOF implementation in
EXPath.

Florent Georges

unread,
Apr 18, 2009, 4:03:21 PM4/18/09
to EXPath
On Apr 18, 9:53 pm, Dimitre Novatchev wrote:

> It will be an overkill to implement dynamic evaluation just for the
> purpose of making function-available() possible.

Yes, I think you're right. But I wonder if first-class object
functions wouldn't be another approach. At first glance, I am not
sure this would require much more work than invoke(), while providing
a far more useful feature.

> One could think of less grandiose mechanisms, such as "deferred
> evaluation" or "suppressed static typechecking".

I wonder whether "suppressed static typechecking" is not that
grandiose ;-)

> If static type checking could be suppressed (and this would be a nice
> meta-function of EXPath), and there was a "try... catch..."

Try/catch... Another useful, missing feature :-)

Florent Georges

unread,
Apr 18, 2009, 4:13:07 PM4/18/09
to EXPath
On Apr 18, 9:56 pm, Dimitre Novatchev wrote:

> Also, it seems that HOF will be present in the next version of
> XQuery, so it would not be useful to create another, competing
> HOF implementation in EXPath.

I don't know. If I am right, first-class function objects (as
try-catch) have been added only in the last XQuery 1.1 WD. I can
be totally wrong, but I don't expect it to pass as a REC this
year. Having a similar definition in EXPath would be also the
opportunity to get feedback before its publication, besides
providing the functionality to not-XQuery 1.1 languages...

But once again, that's more a matter of who's going to work on that
(or not.)

Kurt Cagle

unread,
Apr 19, 2009, 1:49:45 AM4/19/09
to exp...@googlegroups.com
I think the best solution there would be to track the XQ 1.1 development in that space with a shadow namespace, something that can be swapped out like a number of the Saxon methods were. Don't get me wrong - I will be first in line for higher order functionality in XQuery - there are simply too many cases where HOFs are critical for XQuery applications, especially if you're using XQuery as a routing mechanism or as an implementation for XProc (which more or less requires HOFs for some of the more sophisticated functionality, not least of which being <p:xquery/> node itself).

I"m also going to commit a bit of heresy here, but WHY in this case should eval() be considered evil? So long as you properly sandbox for permissions, you're dealing with a language that is already implicitly distributed, where your specific code trajectories may come from multiple distributed sources. It is less efficient, yes, and written badly you can screw yourself over, but that's true of XQuery in general.

As a case in point - suppose that you wanted to set up a query such that the predicate and sorting parameters for that query were fed from external resources. In this case, using an eval makes a huge deal of sense:

let $collection := collection("bar/bat")
let $predicate := myfunc:get-external-predicate("mysource","$entry//myChildElement/text() = 'foo'")
let $sort := myfunc:get-external-sort("mysource","$entry//myChildSortElement ascending")
let $expr := concat("for $entry in $collection where ",$predicate," order by ",$sort," return $entry")
let $result := eval($expr)
return $result

This is of course a not terribly secure case - I see predicate as being a mechanism for converting something like a keyword set from a Search box on a browser into a much more secure query, but the idea is there nonetheless.

I think we need to be careful about not getting so caught up in the notion that something is bad in imperative languages (and there I would agree that eval() is evil) should also be seen as being bad in declarative ones. I'll probably be taken to task for this, but I'm not necessarily ready to abandon eval() without their being a rational reason to do so in the context of the language.



Kurt Cagle
Managing Editor
http://xmlToday.org


Martin Probst

unread,
Apr 19, 2009, 3:29:30 AM4/19/09
to exp...@googlegroups.com
Yes, Higher Order Functions are desperately needed, also for things
like unit tests (a la unit-test($test as function()).

However the current proposal at
http://snelson.org.uk/~jpcs/higher-order-functions.html will not work
for the use case of function-available, as it cannot do dynamic
function calls.

About eval: to make this actually useful, we would need to use some
eval function that evaluates the whole query within the current
context, with namespaces and variables and all. I don't know about
other XQuery implementations, but in xDB this is not going to be easy,
as at run time we have already "forgotten" much of the needed
information and/or transformed it into a more execution-suited format.

I really have a strong dislike to concatenating program statements at
run time, and I think it doesn't make a difference whether we're in a
declarative or imperative programming language. The kind of bugs, the
implementation overhead, and the security problems are all the same.

> This is of course a not terribly secure case - I see predicate as being a
> mechanism for converting something like a keyword set from a Search box on a
> browser into a much more secure query, but the idea is there nonetheless.

That is exactly part of the problem. Having written three different
XQuery parsers, I'd have true pity for someone trying to escape
literals to keep an XQuery injection attack away.

> I think we need to be careful about not getting so caught up in the notion
> that something is bad in imperative languages (and there I would agree that
> eval() is evil) should also be seen as being bad in declarative ones. I'll
> probably be taken to task for this, but I'm not necessarily ready to abandon
> eval() without their being a rational reason to do so in the context of the
> language.

There are use cases for eval, granted. But I think our use case at
hand here - dynamically picking a function to call - is much simpler.
My rule of thumb is if you can get away without using eval, do so. And
I think this is such a case.

Martin

Adam Retter

unread,
Apr 19, 2009, 7:10:58 AM4/19/09
to exp...@googlegroups.com
> I think the entire eXist util: namespace is worth some serious consideration
> here (of course that could be said for a lot of extensions in eXist, but
> that one in particular is just chock full of goodness). For those that don't
> have an implementation handy here's what's supported:

A great endorsement for eXist ;-) But hangon just a second... I agree
that there are a lot of good general purpose functions in there (I am
sure other implementations probably have many of them as well),
however there are several that are very eXist specific (locking,
indexing, optimisation, some of the eval stuff) or out of reach of a
pure XPath effort (just too complicated to make use of in XPath) and
more relevant to EXQuery.

Also the util module has suffered more than any module in eXist for
being a general purpose dump for anything that doesnt really fit into
its own module. Because we had no versioning (am I really starting
that conversation again?!?), we have never been able to remove or tidy
that module. Personally in maybe release 1.6 of eXist (1.4 will be out
soonish and odd versions are development branches), I want to do a
complete overhaul and reorganisation of the modules whilst culling
anything legacy. Yes it may break applications, but we are carrying a
lot of cruft around and its getting to the point where its hard for
developers to locate the function they need from the documentation -
actually EXPath and EXQuery modules could be the perfect excuse ;-)

Adam Retter

unread,
Apr 19, 2009, 7:21:11 AM4/19/09
to exp...@googlegroups.com
2009/4/18 Florent Georges <fgeo...@gmail.com>:


>  I was going to say I didn't see the point of such a function,
> the behavior of which could be provided by a general purpose
> util:eval() function or by first-class function objects.  But
> actually, I guess that could be useful for that exact issue of
> detecting at runtime if a function is supported, without
> requiring the whole machinery for full evaluation or first-class
> object functions.
>
>  Could someone comment on that?

I would always avoid full evaluation where possible.

As a developer with an eye on security I see util:eval() as the devils
own work, for me this is right up there beside native language binding
in XQuery or XSLT. If I can provide constructs which are more limited
then I will always do so. I am not saying that it should not be
available, but in an implementation I am providing, such functionality
will be disabled by default, as it enables too much risk.

I am sure we are all aware of SQL injection attacks, has anyone tried
an XQuery injection attack? I am sure it is possible. With util:eval()
enabled in something like a HTTP REST context and people having easy
access to an eval function and using parameters from POST or GET then
I can see a lot of problems occuring.

Sure such issues are perhaps a developer training issue, but I prefer
perhaps a more proactive approach where if I can prevent stupid
mistakes from happening then everyones life becomes easier hopefully.

Adam Retter

unread,
Apr 19, 2009, 7:25:18 AM4/19/09
to exp...@googlegroups.com
> If static type checking could be suppressed (and this would be a nice
> meta-function of EXPath), and there was a "try... catch..."
> capability, one could write something like ( excuse my ignorance of
> XQuery syntactic rules :)  )
>
>  $foo-available =
>      suppress-static-typechecking
>        {
>           try
>             { (: simple invocation of foo :) foo();  return true;}
>           catch
>             {return false;}
>        }
>

Perhaps I am mistaken, but I wonder if we are not over stepping the
scope of EXPath, EXPath is for XPath and should develop only what is
permissible in XPath surely?

Adam Retter

unread,
Apr 19, 2009, 7:31:53 AM4/19/09
to exp...@googlegroups.com
> I really have a strong dislike to concatenating program statements at
> run time, and I think it doesn't make a difference whether we're in a
> declarative or imperative programming language. The kind of bugs, the
> implementation overhead, and the security problems are all the same.

> That is exactly part of the problem. Having written three different


> XQuery parsers, I'd have true pity for someone trying to escape
> literals to keep an XQuery injection attack away.

> There are use cases for eval, granted. But I think our use case at


> hand here - dynamically picking a function to call - is much simpler.
> My rule of thumb is if you can get away without using eval, do so. And
> I think this is such a case.


I completely agree with all of these statements, some excellent points.

Dimitre Novatchev

unread,
Apr 19, 2009, 10:01:59 AM4/19/09
to exp...@googlegroups.com
On Sun, Apr 19, 2009 at 4:25 AM, Adam Retter <adam....@exquery.org> wrote:
>
>> If static type checking could be suppressed (and this would be a nice
>> meta-function of EXPath), and there was a "try... catch..."
>> capability, one could write something like ( excuse my ignorance of
>> XQuery syntactic rules :)  )
>>
>>  $foo-available =
>>      suppress-static-typechecking
>>        {
>>           try
>>             { (: simple invocation of foo :) foo();  return true;}
>>           catch
>>             {return false;}
>>        }
>>
>
> Perhaps I am mistaken, but I wonder if we are not over stepping the
> scope of EXPath, EXPath is for XPath and should develop only what is
> permissible in XPath surely?

This is exactly why I am asking about defining more strictly Vision,
Purpose and Scope.

For me the best results from EXPath would come not so much from
providing a stadard library of extension functions (certainly this
would be a very good and useful result in itself), but from also
extending the XPath language with at least some new features that were
most asked for .

At present many people have identified at least one feature as badly
neaded: the support for a nested sequence -- a sequence that can have
another sequence as an individual item.

Another often sited feature is HOF (more for XQuery as in XSLT we have
had FXSL for many years).

It seems that W3C are doing something for HOF in XQuery, but why not
address nested sequences in EXPath? An implementation is
straightforward and an average developer (me included) can provide
such in a couple of days.

Some people (most notably Florent) have proposed other extensions to
XPath (such as the Try ... Catch mechanism). While this seems a lot
more tricky to implement in a functional setting, why not address the
issue at all? If implemented properly, the benefits would be huge. A
lot of people are asking how to determine if the document() function
was successful or if there was timeout when consuming a remote
service. I believe that having try... catch would provide a good
mechanism to address such kind of issues.


To conclude, I propose that extending XPath itself (not only by
recommending a set of extension functions) is high priority in the
Vision, Goals and Scope of EXPath.



--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play



>
>
>
>

Florent Georges

unread,
Apr 19, 2009, 10:20:52 AM4/19/09
to EXPath
On Apr 19, 9:29 am, Martin Probst wrote:

> However the current proposal athttp://snelson.org.uk/~jpcs/higher-order-functions.htmlwill not work
> for the use case of function-available, as it cannot do dynamic
> function calls.

Yes, good catch (if I am right, actually dynamic calls are allowed,
but that's because it is not possible to get a function item at
runtime, from a string.)

> About eval: to make this actually useful, we would need to use some
> eval function that evaluates the whole query within the current
> context, with namespaces and variables and all.

That's only one particular case. An eval function should be able to
act on a different context (context item, in-scope namespaces, in-
scope variable bindings, etc.) Even maybe providing the ability to
modify (especially restrict) the available function signatures in the
static context.

I see a general purpose eval module as defining a function to
compile an expression, and other to evaluate the compiled expression,
allowing one to set the exact context to use. A simple eval
(xs:string) function would only be a convenient shortcut then.

> There are use cases for eval, granted. But I think our use case at
> hand here - dynamically picking a function to call - is much simpler.
> My rule of thumb is if you can get away without using eval, do so. And
> I think this is such a case.

Yes, I guess so.

Florent Georges

unread,
Apr 19, 2009, 10:40:10 AM4/19/09
to EXPath
On Apr 19, 4:01 pm, Dimitre Novatchev wrote:

> For me the best results from EXPath would come not so much from
> providing a stadard library of extension functions (certainly this
> would be a very good and useful result in itself), but from also
> extending the XPath language with at least some new features that were
> most asked for .

> At present many people have identified at least one feature as badly
> neaded: the support for a nested sequence -- a sequence that can have
> another sequence as an individual item.

Yes. I think nested sequences would be very beneficial for the
XPath community(ies,) especially allowing complex data structure
preserving the identity of its items. And clearly such features are
more than welcome here.

But I am convinced extension functions remain the best option to
implement them. I would be reluctant to change the XPath grammar
within a processor-independent project.

If you take the example of John's HOF proposal, something similar
could be achieved using extension functions. Instead of my:f#1, use
fun:function('ns:f', 1), providing the function's behavior was
properly defined regarding the static and dynamic contexts.

Of course, discussing how the function-based feature in EXPath could
be translated into a grammar change in, say, XPath 2.1 would be
interesting. But IMHO proposing features in EXPath through grammar
changes would work against an important goal: portability.

I agree you get a point: this is not clear, and should maybe be
clearly stated on the website.

> To conclude, I propose that extending XPath itself (not only by
> recommending a set of extension functions) is high priority in the
> Vision, Goals and Scope of EXPath.

I agree on "extending XPath itself" :-), but the mean of extension
function is the *highly* preferred way of providing them (opposed to
grammar changes in particular.)

Dimitre Novatchev

unread,
Apr 19, 2009, 10:50:27 AM4/19/09
to exp...@googlegroups.com
A long post, Florent,

In just a few words, we agree that a couple of extension functions
(one for a reference to a sequence and another for dereferencing a
sequence) are sufficient for a very basic, rude implementation of
nested sequences.

If nobody would extend XPath itself, I don't mind extending it at the
function level :)


--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play

Adam Retter

unread,
Apr 19, 2009, 10:54:59 AM4/19/09
to exp...@googlegroups.com
> For me the best results from EXPath would come not so much from
> providing a stadard library of extension functions (certainly this
> would be a very good and useful result in itself), but from also
> extending the XPath language with at least some new features that were
> most asked for .

I understand the purpose of the extension functions. But I have some
questions otherwise - When you start extending XPath as a language are
you not really turning it more and more into XQuery (or what the next
version of XQuery is likely to include). Why not just use XQuery
instead of XPath if you need language functionality that XPath does
not have?


> At present many people have identified at least one feature as badly
> neaded: the support for a nested sequence -- a sequence that can have
> another sequence as an individual item.

Excuse my ignorance but I am not a pure XPath developer, my background
is really in XQuery. This may not be the place to ask, but for my sake
can you explain this need briefly - why a sequence of sequences rather
than a node set?

((1,2,3), (8,9,0)) =
<sequence><sequence><item>1</item><item>2</item><item>3</item></sequence><sequence><item>8</item><item>9</item><item>0</item></sequence></sequence>


> Some people (most notably Florent) have proposed other extensions to
> XPath (such as the Try ... Catch  mechanism). While this seems a lot
> more tricky to implement in a functional setting, why not address the
> issue at all? If implemented properly, the benefits would be huge. A
> lot of people are asking how to determine if the document() function
> was successful or if there was timeout when consuming a remote
> service. I believe that having try... catch would provide a good
> mechanism to address such kind of issues.

try/catch would certainly be welcome in XQuery ;-)

Florent Georges

unread,
Apr 19, 2009, 11:00:43 AM4/19/09
to exp...@googlegroups.com
2009/4/19 Dimitre Novatchev wrote:

> In just a few words, we agree that a couple of extension functions
> (one for a reference to a sequence and another for dereferencing a
> sequence) are sufficient for a very basic, rude implementation of
> nested sequences.

That's at least the first step. Once we have that, we could always
consider its drawbacks and new reasonable orientations :-)

Dimitre Novatchev

unread,
Apr 19, 2009, 11:03:55 AM4/19/09
to exp...@googlegroups.com
On Sun, Apr 19, 2009 at 7:54 AM, Adam Retter <adam....@exquery.org> wrote:
>
>> For me the best results from EXPath would come not so much from
>> providing a stadard library of extension functions (certainly this
>> would be a very good and useful result in itself), but from also
>> extending the XPath language with at least some new features that were
>> most asked for .
>
> I understand the purpose of the extension functions. But I have some
> questions otherwise - When you start extending XPath as a language are
> you not really turning it more and more into XQuery (or what the next
> version of XQuery is likely to include). Why not just use XQuery
> instead of XPath if you need language functionality that XPath does
> not have?

Some useful features are not provided by XQuery -- nested sequences
and try...catch, just to name a few.


>
>
>> At present many people have identified at least one feature as badly
>> neaded: the support for a nested sequence -- a sequence that can have
>> another sequence as an individual item.
>
> Excuse my ignorance but I am not a pure XPath developer, my background
> is really in XQuery. This may not be the place to ask, but for my sake
> can you explain this need briefly - why a sequence of sequences rather
> than a node set?
>
> ((1,2,3), (8,9,0)) =
> <sequence><sequence><item>1</item><item>2</item><item>3</item></sequence><sequence><item>8</item><item>9</item><item>0</item></sequence></sequence>
>

Because this is both more awkward and prohibitively expensive. (This
is how a nested sequence *has to be modelled* at present in FXSL, and
this is quite painful).



--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play



>

Florent Georges

unread,
Apr 19, 2009, 11:04:27 AM4/19/09
to exp...@googlegroups.com
2009/4/19 Adam Retter wrote:

> Excuse my ignorance but I am not a pure XPath developer, my background
> is really in XQuery. This may not be the place to ask, but for my sake
> can you explain this need briefly - why a sequence of sequences rather
> than a node set?

> ((1,2,3), (8,9,0)) =
> <sequence><sequence><item>1</item><item>2</item><item>3</item></sequence><sequence><item>8</item><item>9</item><item>0</item></sequence></sequence>

But then, you cannot have complex data structure that preserve every
properties of nodes that you would like to reference from there. For
example their identity or their validation info. Because when you add
an item to a node, it is copied and some properties of the resulting
node are changed from the original one.

> try/catch would certainly be welcome in XQuery ;-)

It is on its way:
http://www.w3.org/TR/2008/WD-xquery-11-20081203/#id-try-catch :-)

Adam Retter

unread,
Apr 19, 2009, 11:10:18 AM4/19/09
to exp...@googlegroups.com
> Some useful features are not provided by XQuery -- nested sequences
> and try...catch,    just to name a few.

Sure but I think it is only a matter of time before HOF and try/catch
will make it into XQuery, we can assist it along the way of course. My
point was that XPath should not turn into XQuery. XPath fulfills a
very simple need (and does it very well) and if you need more
complexity then there is XQuery.


>> ((1,2,3), (8,9,0)) =
>> <sequence><sequence><item>1</item><item>2</item><item>3</item></sequence><sequence><item>8</item><item>9</item><item>0</item></sequence></sequence>
>>
>
> Because this is both more awkward and prohibitively expensive. (This
> is how a nested sequence *has to be modelled* at present in FXSL, and
> this is quite painful).

Whilst trying not to be unrealistic, I am wondering if this is this
not a detail of the underlying implementation? Is it not the case that
if the implementation was more efficient at handling nodes then you
would not need a nested sequence?
If that is the case (it might not be) would it not be better to invest
time improving the performance of the underlying implementation?

Dimitre Novatchev

unread,
Apr 19, 2009, 11:27:25 AM4/19/09
to exp...@googlegroups.com
>> Because this is both more awkward and prohibitively expensive. (This
>> is how a nested sequence *has to be modelled* at present in FXSL, and
>> this is quite painful).
>
> Whilst trying not to be unrealistic, I am wondering if this is this
> not a detail of the underlying implementation? Is it not the case that
> if the implementation was more efficient at handling nodes then you
> would not need a nested sequence?
> If that is the case (it might not be) would it not be better to invest
> time improving the performance of the underlying implementation?
>
>

Suffices to say the performance is O(N^2) and is not going to be less... :(.

Other people can perhaps expalin best, how expensive it is to create
new elements and documents.

And there is the architectural problem: Why should we have a
(non-nested) sequence as a basic datatype but need to represent a
nested sequence (including its non-nested subsequences) in a
completely different way? Even in a student project I would mark this
as a bad decision.

On the other side a nested sequence has so simple implementations that
they are trivial.


--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play




Florent Georges

unread,
Apr 19, 2009, 12:26:13 PM4/19/09
to exp...@googlegroups.com
2009/4/19 Florent Georges wrote:
> 2009/4/19 Adam Retter wrote:

>> Excuse my ignorance but I am not a pure XPath developer, my background
>> is really in XQuery. This may not be the place to ask, but for my sake
>> can you explain this need briefly - why a sequence of sequences rather
>> than a node set?

>> ((1,2,3), (8,9,0)) =
>> <sequence><sequence><item>1</item><item>2</item><item>3</item></sequence><sequence><item>8</item><item>9</item><item>0</item></sequence></sequence>

>  But then, you cannot have complex data structure that preserve every
> properties of nodes that you would like to reference from there.  For
> example their identity or their validation info.  Because when you add
> an item to a node, it is copied and some properties of the resulting
> node are changed from the original one.

Besides, of course, you cannot create nodes in XPath :-)

Kurt Cagle

unread,
Apr 19, 2009, 1:08:42 PM4/19/09
to exp...@googlegroups.com
Adam,

Not disagreeing about util: being a dumping ground, and there's really no question that about 2/3 of those could/should be repartitioned into new namespaces. I just thing they represent a nice sample of utility functions that we should be looking at for expath.

I don't necessarily see the need for versioning here in the namespace - what you need more than anything is an obsolescence mechanism, documentation that can be placed within the existing namespaces docs saying "WARNING: This function is obsolete. Consider using foo() instead. This function will be phased out on Jan. 1, 2010".

My big concern with versioning is that if you have specific versions, you also force vendors to support all versions, which is actually counter to the intent. I'd be more inclined to say that what may need versioning is EXPath itself and that only at major version level. This way, there's a very clearcut division between all libraries, and people aren't playing version whack-a-mole trying to debug their code.

Kurt Cagle
Managing Editor
http://xmlToday.org


Adam Retter

unread,
Apr 19, 2009, 1:54:14 PM4/19/09
to exp...@googlegroups.com
> I don't necessarily see the need for versioning here in the namespace - what
> you need more than anything is an obsolescence mechanism, documentation that
> can be placed within the existing namespaces docs saying "WARNING: This
> function is obsolete. Consider using foo() instead. This function will be
> phased out on Jan. 1, 2010".

In eXist we do have a mechanism for marking functions as deprecated,
with some accompanying documentation - just as you suggested actually
;-) But we then encounter the problem of not knowing how long we
should wait before removing a function in its entirety.

Kurt Cagle

unread,
Apr 19, 2009, 2:12:38 PM4/19/09
to exp...@googlegroups.com
On nested sequences -

I've been thinking about this for a while, and I think it comes back to a data type that isn't in XPath at all - a hash type. The problem is that it begins to get into XPath as an OOP language, though the implementation even in XQuery wouldn't be hard:

hash:create() as ^hash^
hash:get-value($hash-obj as ^hash^,$key as xs:string) as xs:any*
hash:set-value($hash-obj as ^hash^,$key as xs:string, $obj as xs:any*)
hash:serialize($hash-obj as ^hash^) as node()
hash:parse($hashnode as node()) as ^hash^

I'm using the rather odd ^hash^ notation to indicate an object, something which can sort of get away with as long as we specifically don't ask what that object is. serialize and parse would make it possible to convert this object into and out of XML representation. I understand the rational for not doing it in the original spec and its a valid one - such hashes are definitely not declarative, which is why they'd never end up specifically in the W3C spec, but they could definitely serve in an ancillary fashion.


Kurt Cagle
Managing Editor
http://xmlToday.org


Florent Georges

unread,
Apr 19, 2009, 2:59:28 PM4/19/09
to exp...@googlegroups.com
2009/4/19 Kurt Cagle wrote:

> hash:set-value($hash-obj as ^hash^,$key as xs:string, $obj as xs:any*)

Do you mean the hash passed as parameter should be modified as a
side-effect of the function call?

Kurt Cagle

unread,
Apr 19, 2009, 3:29:50 PM4/19/09
to exp...@googlegroups.com
It would have to be. That's the only way that I can see being able to store content in a hash. There is an alternative, of course -

let $hash := hash:set-value($hash-obj as ^hash^,$key as xs:string,$obj as xs:any*) as ^hash^

but that places significant restrictions on scope usage.

However, its the only way that I can see creating sequences within sequences or compound structures, for that matter. Not that happy with the solution myself, which is why I suspect it never made its way into XPath 2, but a hash is a persistent data structure.

Take a look as well at the XQuery Update Facility code - it seems to recognize that side-effect modifications may be unavoidable once you start dealing with update facilities.

 
Kurt Cagle
Managing Editor
http://xmlToday.org


Dimitre Novatchev

unread,
Apr 19, 2009, 3:34:50 PM4/19/09
to exp...@googlegroups.com
Using a hash-like structure is not necessary for implementing a nested sequence.

Moreover, this is an implementation detail and, by definition, any
implementation details are best to be avoided in a specification.


--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play


Kurt Cagle

unread,
Apr 19, 2009, 3:49:26 PM4/19/09
to exp...@googlegroups.com
So how would you create a nested sequence? Short of encoding such a sequence as a sequence of  XML structures, each of which are an encoding of a sequence, I can't see how'd you do it.



Kurt Cagle
Managing Editor
http://xmlToday.org


James Fuller

unread,
Apr 19, 2009, 3:55:17 PM4/19/09
to exp...@googlegroups.com
2009/4/19 Kurt Cagle <kurt....@gmail.com>
So how would you create a nested sequence? Short of encoding such a sequence as a sequence of  XML structures, each of which are an encoding of a sequence, I can't see how'd you do it.

references ?

ta, Jim Fuller
 

Florent Georges

unread,
Apr 19, 2009, 4:11:04 PM4/19/09
to exp...@googlegroups.com
2009/4/19 Kurt Cagle wrote:

First, about side-effects of an extension function, it would be
better to avoid them as much as possible. They introduce
unpredictability in code, and optimizers in existing processors
actually show problems with such extensions.

> So how would you create a nested sequence? Short of encoding such a sequence
> as a sequence of  XML structures, each of which are an encoding of a
> sequence, I can't see how'd you do it.

By using what XSLT 2.0 calls an external object:

http://www.w3.org/TR/xslt20/#external-objects

This is an item(), but neither an atomic type nor a node(). Exactly
as the proposed function() item type. So the exact type is a black
box (and in plain, standard XPath 2.0 can only be represented as
item() in an ItemType:

http://www.w3.org/TR/xpath20/#prod-xpath-ItemType

The user can only pass it to another functions defined as such by
the module (besides adding it to a sequence, for instance in a
variable.) For instance (let's abbreviate a nested sequence by ns,
even if it is not the best option in the XML world, but I don't have
enough imagination right now):

let $ns1 as item() := ns:make-ns((1, 2, 3))
let $ns2 as item() := ns:make-ns((5, 6, 7))
let $s as item()+ := ($ns1, 4, $ns2)
return
( count($s), ns:atomize($s[1]), $s[2], ns:atomize($s[3]) )

that would produce:

3, 1, 2, 3, 4, 5, 6, 7

3 is the length of $s (one nested sequence, one integer, and one
other ns.) Then 1, 2, 3 is the content of the first nested sequence
(that is, the first item of $s,) which must be explicitly atomized
before using its items. 4 is the second item of $s, the integer. And
finally 5, 6, 7 is the content of the last ns (the third item of $s.)

Regards,

Adam Retter

unread,
Apr 19, 2009, 4:22:09 PM4/19/09
to exp...@googlegroups.com
>  This is an item(), but neither an atomic type nor a node().  Exactly
> as the proposed function() item type.  So the exact type is a black
> box (and in plain, standard XPath 2.0 can only be represented as
> item() in an ItemType:

Ouch - It would be my preference to avoid the use of Item at all
possible costs. Passing around an unknown object just feels very
wrong. We used to have a similar situation in eXist where we had a
type to repesent a Java File Object and you could pass that in and out
of various functions - we have subsequently chased that out of the
extension functions almost entirely now.

Although that said, it would seem that Item is appropriate to this
situation if we really cant come up with anything better.

>  The user can only pass it to another functions defined as such by
> the module (besides adding it to a sequence, for instance in a
> variable.)

> even if it is not the best option in the XML world, but I don't have
> enough imagination right now):


Me neither, will give it some thought tomorrow...

Dimitre Novatchev

unread,
Apr 19, 2009, 4:44:46 PM4/19/09
to exp...@googlegroups.com
On Sun, Apr 19, 2009 at 1:22 PM, Adam Retter <adam....@exquery.org> wrote:
>
>>  This is an item(), but neither an atomic type nor a node().  Exactly
>> as the proposed function() item type.  So the exact type is a black
>> box (and in plain, standard XPath 2.0 can only be represented as
>> item() in an ItemType:
>
> Ouch - It would be my preference to avoid the use of Item at all
> possible costs. Passing around an unknown object just feels very
> wrong. We used to have a similar situation in eXist where we had a
> type to repesent a Java File Object and you could pass that in and out
> of various functions - we have subsequently chased that out of the
> extension functions almost entirely now.

We can avoid it by just not speaking about it -- the same way this
topic is avoided in XPath/XQuery/XSLT by not speaking what is inside a
variable that contains a sequence:

<xsl:variable name="mySeq" select="1 to 1000"/>

my:foo($mySeq)


what is contained in $mySeq and is passed to my:foo() above are not
all numbers from 1 to 1000, but it is rather a *reference* to the
sequence 1 to 1000.

XPath and all its implementations already have the reference type, but
they are not speaking about it openly.

Michael Kay calls the reference withs its proper name in a number of
places in his books.

So we do not have to invent anything new, anything frightening -- it
already exists.



We possibly would not even an item() for this type if we cover it well
in expressions like:


(1, makeRef(2 to 10), 3)

or

subsequence(deRef($seq[3]), 2,1)



--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play


>

Kurt Cagle

unread,
Apr 19, 2009, 5:25:37 PM4/19/09
to exp...@googlegroups.com
We can avoid it by just not speaking about it -- the same way this
topic is avoided in XPath/XQuery/XSLT by not speaking what is inside a
variable that contains a sequence:

   <xsl:variable name="mySeq" select="1 to 1000"/>

  my:foo($mySeq)


what is contained in $mySeq and is passed to my:foo() above are not
all numbers from 1 to 1000, but it is rather a *reference* to the
sequence 1 to 1000.

Well, sort of. In XQuery it's a little more explicit:

for $myNum in (1 to 1000) return $myNum
 
But the point is taken.


We possibly would not even an item() for this type if we cover it well
in expressions like:


   (1, makeRef(2 to 10), 3)

or

   subsequence(deRef($seq[3]), 2,1)

It sounds like we're verging dangerously into the realm of <> templates here ;-)

I think one way to think about it here is that we are walking on the edge of formalizing something that has remained unformalized for a while - the underlying relationship between a namespace and an object definition in XSLT/XQuery. Right now, existing modules are pre-OOP - think of them as global static classes. This changes the moment we get into the modality

let $oRef := ns:new($paramSeq...)
let $result := ns:someFn($oRef,$paramSeq...)

At that stage, a module becomes an instantiable class definition. There are a few situations already where this has taken place, the aforementioned anonymous sequence *to* operator being one of them, and we'll run into more once we break non-fungibility rules with XQUF.

I think the question that needs to be determined is whether in fact this design pattern is one that EX* should endorse. It solves a number of problems, but it also introduces a number as well. For instance, even assuming that we establish formal restrictions to make hash() strictly declarative - you can only make a hash table indirectly via two sets of collections, akin to the XSLT index() function, then you can go with such a formal declaration of an instanced object:

let $hash := hash:new($collection1/labels,$collection2/values)
let $val1 := hash:get($hash,"label1")
let $val2 := hash:exists($hash,"label-in-hash")

In a similar vein, you could make explicit the subsequence notation:

let $seq1 := seq:new(("d","e","f"))
let $seq2 := ("a","b",$seq1)
let $val := seq:get($seq2[3],2)

The advantage, as I see it, are that we objectify the informal don't look don't tell rule, essentially identifying OOP constructs as being legitimate XPath entities (and note that this can be used in XPath itself with the for statement, as Dimitre laid out earlier, or via anonymous reference upon a singleton).

The disadvantage is that we end up having to also formalize the type declaration mechanisms, and up with first and second class types. Such objects by reference could only by specified by item() within the established framework, and would require that each type explicitly import some kind of "type:" library in order to handle introspection, or that a convention of including ns:type() and ns:serialize() exist for each such module namespace.

I think its a legitimate either/or question that should probably be decided earlier. My own druthers are to make such objects explicit, and push this back into XPath 2.1 as part of a serious question for that particular effort, but I can see arguments pro and con here.

-- Kurt Cagle

mozer

unread,
Apr 19, 2009, 5:50:15 PM4/19/09
to exp...@googlegroups.com
On Sun, Apr 19, 2009 at 11:25 PM, Kurt Cagle <kurt....@gmail.com> wrote:
>
>> We can avoid it by just not speaking about it -- the same way this
>> topic is avoided in XPath/XQuery/XSLT by not speaking what is inside a
>> variable that contains a sequence:
>>
>>    <xsl:variable name="mySeq" select="1 to 1000"/>
>>
>>   my:foo($mySeq)
>>
>>
>> what is contained in $mySeq and is passed to my:foo() above are not
>> all numbers from 1 to 1000, but it is rather a *reference* to the
>> sequence 1 to 1000.
>
> Well, sort of. In XQuery it's a little more explicit:
>
> for $myNum in (1 to 1000) return $myNum

Well this is also obviously XPath

Xmlizer

Dimitre Novatchev

unread,
Apr 19, 2009, 6:06:35 PM4/19/09
to exp...@googlegroups.com
On Sun, Apr 19, 2009 at 2:25 PM, Kurt Cagle <kurt....@gmail.com> wrote:
>
>> We can avoid it by just not speaking about it -- the same way this
>> topic is avoided in XPath/XQuery/XSLT by not speaking what is inside a
>> variable that contains a sequence:
>>
>>    <xsl:variable name="mySeq" select="1 to 1000"/>
>>
>>   my:foo($mySeq)
>>
>>
>> what is contained in $mySeq and is passed to my:foo() above are not
>> all numbers from 1 to 1000, but it is rather a *reference* to the
>> sequence 1 to 1000.
>
> Well, sort of. In XQuery it's a little more explicit:
>
> for $myNum in (1 to 1000) return $myNum

I think in XQuery one has to use the "let" clause.

In pure XPath it is not possible at all to define a variable that
contains a sequence. This:


> for $myNum in (1 to 1000) return $myNum

is simply equivalent to:

1 to 1000

and this is not a definition of a variable :(


> I think one way to think about it here is that we are walking on the edge of
> formalizing something that has remained unformalized for a while - the
> underlying relationship between a namespace and an object definition in
> XSLT/XQuery. Right now, existing modules are pre-OOP - think of them as
> global static classes. This changes the moment we get into the modality
>
> let $oRef := ns:new($paramSeq...)
> let $result := ns:someFn($oRef,$paramSeq...)
>

There's absolutely nothing special in the above lines and in fact a
person who doesn't know English (doesn't know the meaning of "new")
and OOP, will not make any difference between the above and:

let $myRef := ref($someSeq)
let $result := foo($myRef,$paramSeq...)

The fact that you *think* "new" means calling a constructor to create
a new instance of a type does not at all mean that this will *really*
take place in an actual implementation. In a particular
implementation there might be lazy evaluation, optimization and due to
various reasons creating a ref may actually be a no-op, as this ref
may already exist and be used for various other purposes.


> I think the question that needs to be determined is whether in fact this
> design pattern is one that EX* should endorse. It solves a number of
> problems, but it also introduces a number as well. For instance, even


The reasoning above proves that this is only an imaginary problem. It
would be good to warn any people that might be too influenced by OOP
that no such problem actually exists.

Kurt Cagle

unread,
Apr 19, 2009, 7:32:12 PM4/19/09
to exp...@googlegroups.com
I think in XQuery one has to use the "let" clause.

In pure XPath it is not possible at all to define a variable that
contains a sequence. This:


> for $myNum in (1 to 1000) return $myNum

is simply equivalent to:

 1 to 1000

and this is not a definition of a variable  :(

Admittedly - the problem with the discussion here is that the inability to create variables in XPath means that any entity that IS created has to be anonymous:

(for $myNum in (1 to 1000)[. mod 2 =0] return $myNum)

creates two sequences (the entire sequence and (1 to 1000)), but because you can't create variables, they are simply expressions. However, there are still operations that can be defined upon the expressions overall.
 
> I think one way to think about it here is that we are walking on the edge of
> formalizing something that has remained unformalized for a while - the
> underlying relationship between a namespace and an object definition in
> XSLT/XQuery. Right now, existing modules are pre-OOP - think of them as
> global static classes. This changes the moment we get into the modality
>
> let $oRef := ns:new($paramSeq...)
> let $result := ns:someFn($oRef,$paramSeq...)

There's absolutely nothing special in the above lines and in fact a
person who doesn't know English (doesn't know the meaning of "new")
and OOP, will not make any difference between the above and:

 let $myRef := ref($someSeq)
 let $result := foo($myRef,$paramSeq...)

Well, sort of. The point I'm making is not in the functional refs but in the assumption that these are in a distinct namespace. That is to say, whether using new(), create(), instantiate(), ref() or whatever, there is a difference between:

let $ref1 := ns1:ref()

and

let $ref1 := ns2:ref()

Once you create the idea of a core object class that is tied to a given namespace implementation, that can store an instantiation of that class, and that, require that the instance variable participate in the methods of that class, then you're into the realm of OOP, even if only marginally:

let $result := ns2:foo($ref1)

is meaningless, unless ns2: is designed as a subclass of ns1:.

The fact that you *think* "new" means calling a constructor to create
a new instance of a type does not at all mean that this will *really*
take place in an actual implementation.  In a particular
implementation there might be lazy evaluation, optimization and due to
various reasons creating a ref may actually be a no-op, as this ref
may already exist and be used for various other purposes.

Oh, absolutely agreed, but that wasn't my point. My point is that if you have a namespace that has the potential to create one or more instances of a preferred format for that namespace, that such instances are necessary for the execution of one or more functions within that namespace, and that non-preferred objects when passed into such namespaces generate nonsensical results all point to the potential that namespaces can be conflated with OOP classes. That holds true whether such instances are rendered as Java objects or as XML, though obviously in the latter case such XML can be generated in an ad-hoc fashion and passed in (in other words, such instances are not encapsulated). Whether they are formal OOP is debatable - but I'd argue that they pass the duck test wrt usage.


> I think the question that needs to be determined is whether in fact this
> design pattern is one that EX* should endorse. It solves a number of
> problems, but it also introduces a number as well. For instance, even

The reasoning above proves that this is only an imaginary problem. It
would be good to warn any people that might be too influenced by OOP
that no such problem actually exists.

The problem that we face with XQuery/XPath modularization is that it IS conceptually possible to use an OOP like construction, the question is whether it is advisable. Most languages out there have no such distinction - their structure and syntax is such that they either have no formal mechanism internally to pull off inheritance and as a consequence rely upon syntactical convention to establish namespaces (think PHP4) or they have formal namespace mechanisms and an OOP syntax (think PHP5). XQuery straddles the line between libraries existing in an ad hoc namespace and full OOP. You have a strong namespace mechanism that encourages modularization, but at the same time has no established syntax for doing so.

In effect, we've sidestepped the shift of syntax here (which may actually prove to be a blessing in disguise) but have the mechanism to support OOP with a minimum of formalisms. The reason that I see this as being important is that this makes it possible to build ad hoc types. Should this be a role that EXPath gets involved in?

For instance, suppose that I create a sequence "type" which could be readily stored in an XML format or just as easily in an instantiated Java class:

declare function seq:ref($p_seq  as item()*) as node() {
     let $seq := for $entry in $p_seq return <entry>{$entry}</entry>
    return <sequence expath:ns="http://expath.org/module/sequence" xmlns:expath="http://expath.org">{$seq}</sequence>
     };

declare function seq:item-at($seq as node(),$pos as xs:double) as node() {
    return $seq/entry[$pos]
     };

declare function seq:count($seq as node()) as node() {
    return count($seq/entry[$pos])
     };

declare function seq:deref($seq as node()) as node() {
    let $r_seq := for $entry in $seq return xs:string($entry)
    return $r_seq
     };
 
Note that I'm simplifying shamelessly here - you would be looking at some mechanism to identify and encode existing type for each entry, bounds checking, schema validation and possibly recursion if a given encapsulated sequence contained another encapsulated sequence. However, this is for illustration purposes only.

The point to consider here is the this is an object description - an instantiator (or parser), an accessor, a serializer. As you indicate, the names are less relevant than the larger issue that this is an object, and as an object it will be treated in different ways than a library module of utility functions (global static methods) would.

It provides a different organizing principle if it is, but it opens up functionality as well. Note that this does even have direct implications within an EXPath implementation. Consider the following:

<xsl:copy-of select="seq:deref(seq:ref((seq:ref(("a","b")),seq:ref(("c","d"))))"/>

This would actually create two XML entities as a sequence (<sequence><entry>a</entry><entry>b</entry></sequence>,<sequence><entry>c</entry><entry>d</entry><sequence>) (removing the namespace info), in this implementation, but that's largely unimportant - it could readily be assigned as a neutral item() in another.

The question I would have is whether this modality should be encouraged within EX*, or not. If so, then it suggests that we need to think about the mechanics of such a system and how they could be made consistent across platforms - otherwise, we continue to punt and run into a problem down the road when we have half a dozen different object (inconsistent) instantiation systems. This is why I bring it up.

Kurt

Dimitre Novatchev

unread,
Apr 19, 2009, 7:58:38 PM4/19/09
to exp...@googlegroups.com
With the risk to become too boring and unfathomable to most people:

>
> Admittedly - the problem with the discussion here is that the inability to
> create variables in XPath means that any entity that IS created has to be
> anonymous:
>
> (for $myNum in (1 to 1000)[. mod 2 =0] return $myNum)
>
> creates two sequences (the entire sequence and (1 to 1000)), but because you
> can't create variables, they are simply expressions. However, there are
> still operations that can be defined upon the expressions overall.

Umm... it may be simpler, just:


(1 to 1000)[. mod 2 =0]

> The point I'm making is not in the functional refs but in the
> assumption that these are in a distinct namespace. That is to say, whether
> using new(), create(), instantiate(), ref() or whatever, there is a
> difference between:
>
> let $ref1 := ns1:ref()
>
> and
>
> let $ref1 := ns2:ref()
>
> Once you create the idea of a core object class that is tied to a given
> namespace implementation,

There is nothing that makes us associate a namespace to an object.

Haskell has its modules and a module is like a namespace. If you
import tow modules that have functions with the same name you need to
specify some disambiguation (isn't this exactly so with the XQuery
modules?).

This still doesn't make a module object.


>
> The problem that we face with XQuery/XPath modularization is that it IS
> conceptually possible to use an OOP like construction, the question is
> whether it is advisable.

As explained above, this is not "OOP-like", but just a good
modularization practice.

> The point to consider here is the this is an object description - an
> instantiator (or parser), an accessor, a serializer. As you indicate, the
> names are less relevant than the larger issue that this is an object, and as
> an object it will be treated in different ways than a library module of
> utility functions (global static methods) would.

You may *think* of it as an object description, but in fact it isn't.
People, who don't know about OOP wouldn't agree to this being a
specification of an object and wouldn't care, or worse may be
confused.

They will certainly point out this as a good modularization practice.

It is good to pray to God, no matter that this God is different to
different people :)


>
> The question I would have is whether this modality should be encouraged
> within EX*, or not. If so, then it suggests that we need to think about the
> mechanics of such a system and how they could be made consistent across
> platforms - otherwise, we continue to punt and run into a problem down the
> road when we have half a dozen different object (inconsistent) instantiation
> systems. This is why I bring it up.


I strongly believe that EXPath will better serve its mission if it
embraces a number of good design practices, one of which is
modularity.Not preaching a single religion will also be a definite
plus.

Kurt Cagle

unread,
Apr 19, 2009, 8:33:46 PM4/19/09
to exp...@googlegroups.com
Umm... it may be simpler, just:


    (1 to 1000)[. mod 2 =0]

 It is. It's Sunday, I'm operating on about 4 hours of sleep, sometimes the obvious takes a little while to force its way through the brain.

There is nothing that makes us associate a namespace to an object. 

Haskell has its modules and a module is like a namespace. If you
import tow modules that have functions with the same name you need to
specify some disambiguation (isn't this exactly so with the XQuery
modules?).

This still doesn't make a module object.

You may *think* of it as an object description, but in fact it isn't.
People, who don't know about OOP wouldn't agree to this being a
specification of an object and wouldn't care, or worse may be
confused.

They will certainly point out this as a good modularization practice.

It is good to pray to God, no matter that this God is different to
different people :)

Of course, if you're a Taoist ... :-)

Object programming in general is good modularization practice, save when it becomes so heavily encoded into the language that it allows for no other perspective. One of the reasons I'm not a big fan of Bjarne Stroustrup. However, for many, many people, the idea that you can in fact apply an object-like approach to XQuery development is new and consequently frightening. I'm additionally not sure whether it imposes too heavy a conceptual weight on XQueries as a consequence. I'd be interested in hearing other people's perspectives wrt that.

 
>
> The question I would have is whether this modality should be encouraged
> within EX*, or not. If so, then it suggests that we need to think about the
> mechanics of such a system and how they could be made consistent across
> platforms - otherwise, we continue to punt and run into a problem down the
> road when we have half a dozen different object (inconsistent) instantiation
> systems. This is why I bring it up.


I strongly believe that EXPath will better serve its mission if it
embraces a number of good design practices, one of which is
modularity.Not preaching a single religion will also be a definite
plus.

One can only hope.

Martin Probst

unread,
Apr 20, 2009, 3:40:10 AM4/20/09
to exp...@googlegroups.com
> I'm additionally not sure whether it imposes too heavy a
> conceptual weight on XQueries as a consequence. I'd be interested in hearing
> other people's perspectives wrt that.

I'd be very, very careful in doing things like these.

If you add nested sequences to the type system of XPath, you will have
a lot of specification work to do. How do all the built in operators
work on nested sequences (=, eq, ..)? How do they interact with the
standard function library? Of course you could always say "they don't,
and it's an error", but that might not be very useful then.

Same goes for object orientation. XQuery is a functional language, so
side effects are forbidden. And that is for a very good reason - if
you drop this rule, you loose lazy evaluation and statement
reordering, which are really nice and really important optimization
techniques. The sql:connect extension would for example leak
connections in xDB as lazy evaluation would prevent the disconnect
call from happening.

But object orientation is going to be hardly useful without objects
carrying around state. I know it's possible to have immutable objects
only, but 99% of your users will not expect it to work that way.

If you are extending the language this way, you better very well know
what you're doing. Otherwise, you might end up with a variant of Java
with a really ugly syntax and some special XML processing
capabilities.

I know that quite some people like to use XQuery as a general purpose
programming language, and of course that is where requests for nested
sequences and objects come from, but I'm really not sure if that is a
good idea. I can't quite see a way to extend the language to handle
these use cases without breaking it beyond repair in some areas.

Martin

James Fuller

unread,
Apr 20, 2009, 6:29:11 AM4/20/09
to exp...@googlegroups.com


2009/4/20 Martin Probst <ma...@martin-probst.com>

I know that quite some people like to use XQuery as a general purpose
programming language, and of course that is where requests for nested
sequences and objects come from, but I'm really not sure if that is a
good idea. I can't quite see a way to extend the language to handle
these use cases without breaking it beyond repair in some areas.

I especially do not want to reformulate and embed OO concepts at expath or exquery level; but I do want to have 'just enough' added to the language to make it a pragmatic tool.

stepping back a bit, the real problem is that in web programming we have 3 domains in terms of scope/scale ...

I) the web: for 90% of the web a simple general purpose language on the server side just needs to do a few things and do them well. Dynamic languages means you can opt into a watered down version of OO or opt out ... Perl gets this right by allowing just about any computing approach (imperative, functional, OO, etc...) but thats my own personal opinion.

II) enterpise: at the enterprise level, OO rules because, well we need to enable hundreds of developers to have some useful output and I will admit things like Java and its embedded OO notion is one way to go. A lot of specifications and software get a bias towards enterprise level requirements because the larger standards orgs have representation whose interests are firmly at this scale. The funny thing I have found though is that most of the effective work at the enterprise scale gets done by teams of less then 5 senior people ... the hundreds tend to work on the periphery as 'nurses' to the chief surgeons. Sometimes I think there is a bit of 'chinese wall' building but in general I can see how OO promises to enable more output with more developers but I do think our toolchain, specs, and technologies are bent towards doing the will of the 'few' versus the 'many'.

III) planet wide: at this scale we see that people are gaining most success with simple algorithms ... mapreduce, etc .... it will be interesting to see what computing paradigm emerges with virtualisation/parallel computing.

Out of the above 3 domains, there are many many more of the I) type and thats what interests me and what I see as problematic with standards/specification processes mainly being pitched at II) type scenarios.

Getting back to the point, allowing references would enable nested sequences and we could make it very straightforward in that a reference is just a number and existing type; then provide a function to work on that number and retrieve data associated with it ... this is simple and would require no tinkering at any deep level within any existing spec.

The reasons why I/we are drifting towards considering higher order abstractions with XQuery is that solving problems by functional decomposition is difficult to manage over time, especially if reuse mechanisms are lacking as they are in the original XQuery spec. If we had modules a bit more useful then things would be fine ... but thats a discussion I will bring over to EXQuery.

cheers, Jim Fuller






 


Martin



Martin Probst

unread,
Apr 20, 2009, 6:51:20 AM4/20/09
to exp...@googlegroups.com, exq...@googlegroups.com
CC'ing exquery, even though I guess most people are on both lists anyways?

> I especially do not want to reformulate and embed OO concepts at expath or
> exquery level; but I do want to have 'just enough' added to the language to
> make it a pragmatic tool.

My problem with a pragmatic tool is that pragmatism tends to break
certain kinds of scrutiny, and you might well end up with designing
language extensions that are extremely pragmatic, but totally break
certain use cases.

One of these use cases are certain optimizations, and that is what
XQuery was designed to do well in the first place. It's already a hell
to optimize currently, I'd rather not see more complexity added there.
I'm particularly wary of the side-effects adding things. They are
indeed very pragmatic, but IMHO totally break the language in very
important aspects. They do work in one certain implementation, but
that's clearly not enough, at least to me.

About application use cases: there are many interesting domains, and
certainly you can achieve a lot with XQuery. But I'd rather have a
programming environment that lets me fall back to Java (Python, Ruby,
...) or something else when necessary than shoe-horning lots of
features into XQuery.

It's very easy to break a language beyond any recognition by
pragmatically adding features - see PHP for an example. We shouldn't
do that. I'm all in favor of adding small things here and there that
enable certain well defined use cases (like HOF or dynamic function
invocation, better HTTP access and so on), but IMHO we should restrain
from significantly changing the language.

Martin

James Fuller

unread,
Apr 20, 2009, 7:30:46 AM4/20/09
to exp...@googlegroups.com, exq...@googlegroups.com


2009/4/20 Martin Probst <ma...@martin-probst.com>


CC'ing exquery, even though I guess most people are on both lists anyways?

> I especially do not want to reformulate and embed OO concepts at expath or
> exquery level; but I do want to have 'just enough' added to the language to
> make it a pragmatic tool.

My problem with a pragmatic tool is that pragmatism tends to break
certain kinds of scrutiny, and you might well end up with designing
language extensions that are extremely pragmatic, but totally break
certain use cases.

yes, but at the end of the day we need to get work done; we will soon be getting to the cathedral/marketplace permatopic done this line ... instead of upfront design lets let community do what they *want*.


One of these use cases are certain optimizations, and that is what
XQuery was designed to do well in the first place. It's already a hell
to optimize currently, I'd rather not see more complexity added there.
I'm particularly wary of the side-effects adding things. They are
indeed very pragmatic, but IMHO totally break the language in very
important aspects. They do work in one certain implementation, but
that's clearly not enough, at least to me.

I think you and I are in agreement, but perhaps you are looking via imple pov  ... there will always be an option to not implement possibly contentious modules, which I wouldn't consider in core list.

What I don't think expath/exquery should do is make decisions against lets say having someone link XQuery up to a coffee machine ... lets embrace the community let them do whatever they want ... as long as we only allow modules in the core that are not issues then we avoid the issue of debating contentious things only at the point we have something to debate.


About application use cases: there are many interesting domains, and
certainly you can achieve a lot with XQuery. But I'd rather have a
programming environment that lets me fall back to Java (Python, Ruby,
...) or something else when necessary than shoe-horning lots of
features into XQuery.

I am not suggesting to shoe horn anything, I am discussing procedure.

It's very easy to break a language beyond any recognition by
pragmatically adding features - see PHP for an example. We shouldn't

completely agree with you,
 

do that. I'm all in favor of adding small things here and there that
enable certain well defined use cases (like HOF or dynamic function
invocation, better HTTP access and so on), but IMHO we should restrain
from significantly changing the language.

I propose the same outcome but a laissez faire approach... I would rather allow everything and let social democracy dictate if;

a) a human steps up to come forward to define a module and then an implementation becomes available, all choices down to said humans doing the work

*and*

b) expath/exquery members review and vote for inclusion inside of core expath/exquery at that point in time

lets focus on modules that we can agree on now ...

Math module ? anything else ?

IMO expath core should look like the tip of an iceberg, where the visible modules are core and there being an active community underneath cooking up ideas along any manner of their choosing ... lets not stifle anything by presupposing now anything (past quality and technical correctness) and just provide infrastructure, metadata, and simple procedures.

cheers, Jim

Florent Georges

unread,
Apr 20, 2009, 12:39:03 PM4/20/09
to exp...@googlegroups.com
2009/4/19 Adam Retter wrote:

>>  This is an item(), but neither an atomic type nor a node().  Exactly
>> as the proposed function() item type.  So the exact type is a black
>> box (and in plain, standard XPath 2.0 can only be represented as
>> item() in an ItemType:

> Ouch - It would be my preference to avoid the use of Item at all
> possible costs.

I understand this concern. But on the other hand, that's really on
purpose here. We do not want to impose more restriction on this type
(like "it must be a node()," or "it must be a xs:string.") We just
want *exactly one* item. And one cannot do anything else than passing
it to some other functions of this module.

If we were defining a new version of XPath, we could add a new type,
sibling to node(). And provide an ItemType as "sequence-ref()" or
"nested-sequence()." But to only introduce a set of extension
functions, without changing the grammar, we can just stay with
"item()."

Furthermore, nested sequences will typically used to build
heterogeneous sequences (where the SequenceType can not really be more
precise than "item()+".) When you have a sequence of strings and
integers, you cannot precise that fact, only say that you can have
several items: item()+.

Of course, it must be carefully designed to be sure standard F&O are
properly handled (you could do almost nothing with this type excepted
with the functions explicitly designed to deal with it.)

The goal is to enable building complex data structures. But then,
this is the responsibility of the developer to explicitly handle
conversions between those structures and the traditional sequences of
XDM.

Florent Georges

unread,
Apr 20, 2009, 12:53:34 PM4/20/09
to exp...@googlegroups.com
2009/4/19 Dimitre Novatchev wrote:

> XPath and all its implementations already have the reference type, but
> they are not speaking about it openly.

I am a bit surprised to see this affirmation on a quite regular
basis. In my very humble opinion, XPath does not have anything like
this. Indeed, implementations will not copy all sequence's values if
it is used at several places, but this is just an implementation
"detail." Sequences are defined by value, and do not have any
identity.

But I might be wrong.

> Michael Kay calls the reference withs its proper name in a number of
> places in his books.

Do you have any precise reference (well, I mean pointer, well, you know :-p) ?

Florent Georges

unread,
Apr 20, 2009, 12:59:42 PM4/20/09
to exp...@googlegroups.com
2009/4/20 Dimitre Novatchev wrote:

>> The problem that we face with XQuery/XPath modularization is
>> that it IS conceptually possible to use an OOP like
>> construction, the question is whether it is advisable.

> As explained above, this is not "OOP-like", but just a good
> modularization practice.

Yes, I agree with Dimitre. IMHO this is "just" encapsulation.
While this is one very important principle of object orientation,
this is not the only one, and this does not make something object
oriented by itself.

And I do think encapsulation is very valuable in X*, and that's
one reason I'd really like to have the ability to nest sequences:
to be able to define complex data structures, encapsulated by
function libraries.

Florent Georges

unread,
Apr 20, 2009, 1:14:50 PM4/20/09
to exp...@googlegroups.com
2009/4/20 Martin Probst wrote:

> If you add nested sequences to the type system of XPath, you
> will have a lot of specification work to do. How do all the
> built in operators work on nested sequences (=, eq, ..)? How do
> they interact with the standard function library? Of course you
> could always say "they don't, and it's an error", but that
> might not be very useful then.

Funny, I do think this is exactly how it would be useful.

IMHO the goal is not to define black magic rules to decide
automagically when a sequence has to be nested or unnested, but
instead to provide a way to explicitly nest or unnest sequences.
In almost any other cases, an error should be thrown: with value
comparison operators (maybe also with general comparison ops, or
just return false,) with fn:data() and fn:string(), if tried to
be added to a tree, etc.

That would guarantee to not have any silent, unwanted result:
either the handling is explicit, or we get an error.

Dimitre Novatchev

unread,
Apr 20, 2009, 1:22:21 PM4/20/09
to exp...@googlegroups.com
>> Michael Kay calls the reference withs its proper name in a number of
>> places in his books.
>
> Do you have any precise reference (well, I mean pointer, well, you know :-p) ?



There was another discussion on this topic not long ago, which you
probably remember well, in the EXSLT list where I provided a number of
citations (including page numbers) from a number of books by Dr. Kay.
AFAIK his statements to the same effect can be found in his
lists/newsgroups replies, too.



--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play



Florent Georges

unread,
Apr 20, 2009, 1:45:37 PM4/20/09
to exp...@googlegroups.com
2009/4/20 Dimitre Novatchev wrote:

>>> Michael Kay calls the reference withs its proper name in a
>>> number of places in his books.

>> Do you have any precise reference (well, I mean pointer, well,
>> you know :-p) ?

> There was another discussion on this topic not long ago, which
> you probably remember well, in the EXSLT list where I provided
> a number of citations (including page numbers) from a number of
> books by Dr. Kay. AFAIK his statements to the same effect can
> be found in his lists/newsgroups replies, too.

Thanks. I found for instance the following from EXSLT list
http://lists.fourthought.com/pipermail/exslt/2008-December/001782.html:

|> The <xsl:sequence> instruction ... is the only XSLT
|> instruction (with the exception of <xsl:perform-sort>) that
|> can return references to existing nodes, as distinct from
|> newly constructed nodes.

Well, in this case, I would say the important words are "as
distinct from newly constructed nodes," using "references" is
mainly to contrast with that. You can equally say "that can
return existing nodes..." I am not sure this is enough to say
"XPath has the reference type."

Nodes are added to sequences by identity (aka by reference) but
I don't think that's the same thing as having a reference type.

Regards,

Dimitre Novatchev

unread,
Apr 20, 2009, 2:24:57 PM4/20/09
to exp...@googlegroups.com
> |> The <xsl:sequence> instruction ... is the only XSLT
> |> instruction (with the exception of <xsl:perform-sort>) that
> |> can return references to existing nodes, as distinct from
> |> newly constructed nodes.
>
> Well, in this case, I would say the important words are "as
> distinct from newly constructed nodes," using "references" is
> mainly to contrast with that. You can equally say "that can
> return existing nodes..." I am not sure this is enough to say
> "XPath has the reference type."


Florent,

it is not so important how you (or I) feel about that, what is
important is *the fact* that references are *de facto* already there
in XPath.


We may curve and force our tongues not to say the "dirty word", but
this will not change reality. :)




--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play



Florent Georges

unread,
Apr 20, 2009, 2:49:26 PM4/20/09
to exp...@googlegroups.com
2009/4/20 Dimitre Novatchev wrote:

> it is not so important how you (or I) feel about that, what is
> important is *the fact* that references are *de facto* already there
> in XPath.

Sure. You just haven't convinced me yet about that fact :-)

Actually, I simply don't see the point to say "there is a reference
type in XPath; it is not defined in the spec, you cannot use it, but
it is there." Or I completely misunderstood you.

Dimitre Novatchev

unread,
Apr 20, 2009, 3:34:23 PM4/20/09
to exp...@googlegroups.com
On Mon, Apr 20, 2009 at 11:49 AM, Florent Georges <fgeo...@gmail.com> wrote:
>
> 2009/4/20 Dimitre Novatchev wrote:
>
>> it is not so important how you (or I) feel about that, what is
>> important is *the fact* that references are *de facto* already there
>> in XPath.
>
>  Sure.  You just haven't convinced me yet about that fact :-)

In case if it were important, I would probably try.

>
>  Actually, I simply don't see the point to say "there is a reference
> type in XPath; it is not defined in the spec,

Actually the Spec defines this type, although the word "reference" is not used.

> you cannot use it, but

Not at all -- everyone always uses it whenever using a sequence.


A single node cannot be in two different items, at two different
positions, at the same time, but its references can.


One could prefer to regard a sequence that contains a given node
referenced more than once, as something containing "black holes", only
in order to avoid using the word "reference": this is their
problem.

If you prefer to use the term "black holes" instead of "references",
we could still have a function:

black-hole(node)

and

de-black-hole(black-hole)



Or, to use less extravagant terminology, we could most likely agree
that a sequence that contains a node has "something that uniquely
identifies the node". It is difficult to disagree with this fact,
doing so will contradict the capability of a sequence to select that
node at that particular position.

So, we can capture this "something that uniquely identifies the node"
in a function:

something-that-uniquely-identifies-the-node(node)

and

de-something-that-uniquely-identifies-the-node(something-that-uniquely-identifies-the-node)


We could use any other words that are of your liking and I promise
never to write any more the word "***erence".

--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play



>

Florent Georges

unread,
Apr 20, 2009, 4:12:23 PM4/20/09
to exp...@googlegroups.com
2009/4/20 Dimitre Novatchev wrote:

> A single node cannot be in two different items, at two different
> positions, at the same time, but its references can.

That's not what I understand from
http://www.w3.org/TR/xpath-datamodel/#sequences. Maybe, if we
continue this discussion, we should do so on XSL List?

Adam Retter

unread,
Apr 20, 2009, 4:52:11 PM4/20/09
to exp...@googlegroups.com
> If you add nested sequences to the type system of XPath, you will have
> a lot of specification work to do. How do all the built in operators
> work on nested sequences (=, eq, ..)? How do they interact with the
> standard function library? Of course you could always say "they don't,
> and it's an error", but that might not be very useful then.

Personally, I think true nested sequences should be the responsibility
of the W3C WG. However, if someone wishes to add an extension module
specification to EXPath in the mean time for something that imitates
the functionality of a nested sequence then they are more than
welcome. Please note that I said 'extension module', in my opinion
unofficial extensions to the XPath language itself will prove too
costly.

> Same goes for object orientation. XQuery is a functional language, so
> side effects are forbidden. And that is for a very good reason - if
> you drop this rule, you loose lazy evaluation and statement
> reordering, which are really nice and really important optimization
> techniques. The sql:connect extension would for example leak
> connections in xDB as lazy evaluation would prevent the disconnect
> call from happening.

I have no interest in seeing Object Orientation added. I completely
agree that side-effects in XQuery are a bad idea from the point of
lazy evaluation and optimization and I will always try and avoid such
things if possible.

However this is where I will start to diverge from your view - These
are extension modules for doing things that the language never
intended. People want these additions in my experience, which is what
has led me to this point today. If I need to provide some
functionality that can only be achieved with side effects, then I will
add that functionality. The assumption that I make is that it is only
where I have this functionality that the implementation will loose
optimal performance - is that a correct assumption? If so then that is
a price I am happy with.

With regards the sql:connect() example I used, perhaps the example
could be improved with regards to side-effects, it is not actually the
sql module that I implemented for eXist. The sql module in eXist has
no close() function, it automatically cleans up open connections when
the XQuery finishes execution - more side effects ;-p

sql:execute($connectionString as xs:string, $username as xs:string,
$password as xs:string, $sql as xs:string) as element(sql:results)

Perhaps that would be more side-effect free? It would then be upto the
implementation whether to do that as an atomic side-effect free
operation, or whether to perhaps underneath the hood use some sort of
sql connection pooling etc.

> If you are extending the language this way, you better very well know
> what you're doing. Otherwise, you might end up with a variant of Java
> with a really ugly syntax and some special XML processing
> capabilities.

Yuck!

> I know that quite some people like to use XQuery as a general purpose
> programming language, and of course that is where requests for nested
> sequences and objects come from, but I'm really not sure if that is a
> good idea. I can't quite see a way to extend the language to handle
> these use cases without breaking it beyond repair in some areas.

I do a lot of web application development in XQuery, personally I
havent wanted nested sequences or objects yet. But isnt this about
XPath?

Florent Georges

unread,
Apr 20, 2009, 5:09:59 PM4/20/09
to exp...@googlegroups.com
2009/4/20 Adam Retter wrote:

> sql:execute($connectionString as xs:string, $username as xs:string,
> $password as xs:string, $sql as xs:string) as element(sql:results)

> Perhaps that would be more side-effect free?

Well, a SQL extension shouldn't be totally free of side-effect ;-)

Reply all
Reply to author
Forward
0 new messages