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
  [EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>

  O: 303.542.2172
  C: 303.915.2771
  F: 303.544.0522

  www.FlatironsSolutions.com<http://www.flatironssolutions.com/>
  An Inc. 500 Company

________________________________
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Parthiban.K
Sent: Wednesday, May 21, 2008 9:52 AM
To: [email protected]
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
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to