Solution 1: Binding an external variable
This means you will first have to store the XML data as java variable and then pass it on to BaseX. You can certainly do so, it will look something like that:
declare variable $t as xs:string external;
parse-xml($t)
Solution 2: Use fetch()
fetch:text()
and fetch:binary()
are streamable, but parse-xml
will materialize the string (be careful, the function is called parse-xml()
not parse()
as stated in your question.
parse-xml(fetch:text("YOUR-URI"))
Solution 3: Getting the data directly within XQuery
You can also simply retrieve your data from the web service using the http module:
http:send-request(<http:request method='get'></http:request>, "YOUR-URI")[2]
Solution 3 seems to me the easiest way, if you don't further need this result in the Java code. Otherwise you might want to stick to solution 1.