a note on client/server interface

Thursday, 23 September 2010 · 2 messages
GB
Godmar Back23 Sep 2010 07:53 #
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.
AW
Andreas Weiler23 Sep 2010 11:10 #
Dear Godmar, as i understand you could probably use the following... For Example in the php binding:
$external = "<xml>test</xml>";
$query = 'xquery declare variable $entry as xs:anyAtomicType :=
'.$external.'; for $i in 1 to 2 return $entry';
So the xml snippet is just send once to the server. Kind regards, Andreas
Quoted text · Godmar Back · 46 lines
Godmar Back schrieb: > > 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. > > ------------------------------------------------------------------------ > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >

⚡Generated with XQuery