[MarkLogic Dev General] How to pass a node object as parameter
toxquery from java
Rix, Brad
Brad.Rix at flatironssolutions.com
Wed May 21 09:08:52 PDT 2008
You can change your input to be a string:
define variable $content as xs:string external
then, convert your string to a node in your code:
let $content-node := xdmp:unquote($content)
Hence, you will still pass in as a string from Java as you are already doing.
Brad Rix
Consultant
Brad.Rix at FlatironsSolutions.com<mailto:Brad.Rix at FlatironsSolutions.com>
O: 303.542.2172
C: 303.915.2771
F: 303.544.0522
www.FlatironsSolutions.com<http://www.flatironssolutions.com/>
An Inc. 500 Company
________________________________
From: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] On Behalf Of Parthiban.K
Sent: Wednesday, May 21, 2008 9:52 AM
To: general at developer.marklogic.com
Subject: [MarkLogic Dev General] How to pass a node object as parameter toxquery from java
Hi,
How to pass a node object as parameter to xquery from java.
Scenario is
we have an xquery file as "insert.xqy" which looks like
define variable $uri as xs:string external
define variable $content as node() external
xdmp:document-insert($uri,$content)
From java we are passing parameters to the xquery using xcc Api like
String content = "<employee> <name>dhana</name></employee>";
ContentSource contentSource = ContentSourceFactory.newContentSource("localhost",xx,"xxxxx","xxx");
Session session = contentSource.newSession();
ModuleInvoke invoke = session.newModuleInvoke(null);
RequestOptions requestOptions = new RequestOptions();
invoke.setOptions(requestOptions);
invoke.setModuleUri("/insert.xqy");
invoke.setNewStringVariable("uri","/cam/db/sample.xml");
invoke.setNewStringVariable("content",content);
//invoke.setNewVariable("content", ValueType.NODE,content); we are trying to set the value like this it throw following exception
com.marklogic.xcc.exceptions.UnimplementedFeatureException: Setting variables of type XdmNode is not supported
try {
session.submitRequest(invoke);
} catch (RequestException e) {
e.printStackTrace();
}
document-insert() method take 2nd argument as node but In our case we have the xml as string ,so How to pass xml as node to xquery?
Thanks in Advance
Regards
Parthiban.K
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://xqzone.marklogic.com/pipermail/general/attachments/20080521/eeb02820/attachment-0001.html
More information about the General
mailing list