Hi Mike,
I could create a new Java String with a complete XQUery statement that includes a "let $part :=", but I come from an SQL world where we prepare an SQL statement with ? placeholders and then provide host variables with various values at run time, so the binding of variables to a "static" query seemed more natural and efficient :-)
This makes complete sense. In some equivalent Java code, you can specify the type of a variable (see the attached example code). As I see right now, it could make sense to add a third column in the GUI dialog.
<partlist> <part id="1"><part id="2" /></part> </partlist>
Note that the < and > have been converted to < >
To be strict – even if that won’t help you here – < and > is not converted to < and >, but your input string will be inserted as text node. However, as soon as this text is serialized, the special characters will be output in their entity representation.
Conclusion:
o The behavior of let $path := and declaring $path external produces different results.
In your XQuery expression, it can be derived from the query syntax that you want to bind XML to the variable, and not a string. This is not possible with external input, because it may as well be a string, number, etc. See the following example:
(: will output 6 if "5" is bound to "$x" :) declare variable $x external; $x + 5
By default, external input will always be treated as item of type xs:untypedAtomic (which basically means that it does not have a particular type).
However, as you will see in the Java code, you can specify the input type via the .bind() functions.
o Binding variables to XML that uses namespaces makes inserting nodes difficult because the the xml must be modified to include xmlns:
The reason here is that your input will already be bound to the query before the query is evaluated (and at that stage, any namespace declaration in your query cannot be utilized). Maybe the thing to remember is: If you want to bind XML, it must be well-formed XML – and <asy:part id="2"/> itself is not well-formed.
Does this help? Could you tell us where this <asy:part id="2"/> fragment comes from? Is it the result of another query, or possibly a DOM node, which you could possibly directly bind to the query before working with the string representation?
Christian