Should the client/server interface support the declaration of external
variables?
Right now, consider an XQuery such as this one (simplified form shown)
declare variable *$entry* as xs:anyAtomicType external;
return insert node
<entry>
<title>Copy of { *$entry*//atom:title/text() }</title>
{ *$entry*/libx:module | *$entry*/libx:package | *$entry*/libx:libapp
}
</entry>
into $feed
Suppose "entry" is an element rendered into a blob of XML of 1000 characters
and markup. Before we can send above XQuery to the BaseX server, we have to
replace all instances of '$entry' with the actual XML (as per the previous
discussion that XQJ is deprecated and the client/server interface is the
preferred way to communicate with BaseX).
This means that we're sending roughly 4x the amount of data (note that
$entry is used four times above), just to be able to say
"$entry//atom:title/text()". This can easily lead to unexpected performance
as queries become more complicated; in addition and more importantly, it
makes it really tough to debug the expanded XQuery if there is a need.
Why not extend the protocol so that a client can define the external
variables in an XQuery first?
- Godmar
ps: I understand that I could work around this by introducing additional
variables with let, as in
let $dummy = $entry ...
and then using $dummy//atom:title/text() etc. Awkward.