|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] Programmatically constructing sequences ("a", "b", "c") for XQueryMichael Ludwig mlu at as-guides.comMon Aug 10 19:42:20 PDT 2009
Michael Ludwig schrieb:
> I think I know what the problem is. The XmlValue constructor does not
> seem designed to accept sequences. What I mean to be a sequence -
> ('eins','zwei','drei') - is interpreted as a literal string.
>
> So I think a (somewhat kludgy) solution would be to construct a mini
> document from the input parameters, store it in the database and then
> join against that:
>
> <Params>
> <F>eins</F>
> <F>zwei</F>
> <F>drei</F>
> </Params>
>
> Or, preferably, use an XmlResolver. Much better than storing
> parameters in the database, if only temporarily.
For the record, these clumsy solutions aren't needed. Instead, as Andrew
Welch pointed out, the solution is to not abuse the XmlValue interface,
to simply pass in the string as a string with a suitable delimiter (like
"eins,zwei,drei") and construct the sequence of strings at the XQuery
level using the tokenize() function.
String query =
"declare variable $files as xs:string+ := tokenize($param, ','); " +
"for $d in collection('ab')[//File = $files] order by $d/@ts return $d";
...
xqc.setVariableValue("param", new XmlValue("eins,zwei,drei"));
(Or construct the XmlValue dynamically.)
--
Michael Ludwig
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






