[英]Java example to query XML stream / string using BaseX
I trying to write Java code to use BaseX in local mode to query XML returned by hitting a web service. 我试图编写Java代码以在本地模式下使用BaseX来查询通过单击Web服务返回的XML。
I'm not sure about the different ways of passing the XML. 我不确定传递XML的不同方式。 Should I
我是不是该
fn:parse()
, fn:parse()
, fetch
module, fetch
模块, Is there any other XQuery 3.0 processor with similar capabilities and in built modules? 内置模块中是否还有其他具有类似功能的XQuery 3.0处理器?
This means you will first have to store the XML data as java variable and then pass it on to BaseX. 这意味着您首先必须将XML数据存储为java变量,然后将其传递给BaseX。 You can certainly do so, it will look something like that:
您当然可以这样做,它看起来像这样:
declare variable $t as xs:string external;
parse-xml($t)
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. fetch:text()
和fetch:binary()
可以流式传输,但是parse-xml
将具体化该字符串(注意,该函数称为parse-xml()
而不是您的问题所述的parse()
。
parse-xml(fetch:text("YOUR-URI"))
You can also simply retrieve your data from the web service using the http module: 您还可以使用http模块简单地从Web服务检索数据:
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. 在我看来,解决方案3是最简单的方法,如果您在Java代码中不再需要此结果的话。 Otherwise you might want to stick to solution 1.
否则,您可能要坚持解决方案1。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.