[xsl] Xquery-Update

Subject: [xsl] Xquery-Update
From: <deepa.tigadi@xxxxxxxxx>
Date: Thu, 28 Feb 2008 17:14:01 +0530
Hi

Hi
I am trying to use xquery-update through Dom3 Api reference(xqilla)
1.Can you guide me how to  implement it. Currently I am trying with this code.
Can u please have a look into it.
Here I am confused with how to use these classes can you guide me how to use
it in proper way with explanation.
Please consider the below part of code here I am making use of Xqilla ,
XQillaConfiguration, and DynamicContext Classes, I know by these classes we
can query but I am not getting proper usage of it.
Can u tell me
1 how to use it  for query update using document pointer
2 Is it possible to use it for multiple document pointers if so please provide
me steps with proper description of it.(I tried with URIResolver class but I
am not getting it what are the proper parameters).

If possible provide me the code with explanation (see this is the part of the
code where I am getting problem:-

XercesConfiguration xercesconfig;

 XQillaConfiguration* config= xercesconfig::createNode (document, const
DynamicContext *context);


DynamicContext* context=xqilla.createContext(XQilla::UPDATE,config);
     AutoDelete<XQQuery> query(xqilla.parse(X("insert node
<PSE:clAgentFileTransferProtocol>20</PSE:clAgentFileTransferProtocol> after
foo:ConfigDataFile/foo:configData/PSE:PSE/PSE:mclbSrvLoginLocalUserTable/PSE:
mclbSrvLoginLocalUserEntry[@
mclbSrvLoginLocalUserName=\"wimax\"]/PSE:mclbSrvLoginLocalUserPassword")));
   /* AutoDelete<DynamicContext>
context(query->createDynamicContext(document));*/
     Result result = query->execute(context);

     Item::Ptr item;
    while(item = result->next(context)) {
        std::cout << UTF8(item->asString(context)) << std::endl;
    }
xqillaPlatformUtils::terminate();


Below is written complete code...






#include <iostream>
#include <xqilla/xqilla-simple.hpp>
#include <XercesConfiguration.hpp>

#include <xercesc/dom/DOM.hpp>
#include <xercesc/framework/StdOutFormatTarget.hpp>
#include <xqilla/xqilla-dom3.hpp>
#include <xqilla/simple-api/XQilla.hpp>
#include <xqilla/context/DynamicContext.hpp>
#include <StdOutFormatTarget.hpp>
using namespace std;

XERCES_CPP_NAMESPACE_USE;

int main(int argc, char *argv[]) {
                std::cerr << "startsddh" << std::endl;
        // Initialise Xerces-C and XQilla using XQillaPlatformUtils
        XQillaPlatformUtils::initialize();

        // Get the XQilla DOMImplementation object

XQilla xqilla;
        DOMImplementation *xqillaImplementation =
                DOMImplementationRegistry::getDOMImplementation(X("XPath2
3.0"));



        // Create a DOMBuilder object

        DOMBuilder *builder =
xqillaImplementation->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS,
0);
        builder->setFeature(X("namespaces"), true);
                                                                 
  builder->setFeature(X("http://apache.org/xml/features/validation/schema";),
true);
        builder->setFeature(X("validation"), true);

        // Parse a DOMDocument
 DOMDocument *document = builder->parseURI("NECB.xml");
        if(document == 0) {
                std::cerr << "Document not found." << std::endl;
                return 1;



 XQillaNSResolver* nsResolver =
(XQillaNSResolver*)document->createNSResolver(0);


 const XMLCh *n1 = XMLString::transcode("foo");
        const XMLCh *ns1 = XMLString::transcode("Liberty-AP_XML");
        nsResolver->addNamespaceBinding(n1,ns1);

        const XMLCh *n2 = XMLString::transcode("PSE");
        const XMLCh *ns2 = XMLString::transcode("PSE");
        nsResolver->addNamespaceBinding(n2,ns2);

        const XMLCh *n4 = XMLString::transcode("CLM");
        const XMLCh *ns4 = XMLString::transcode("CLM");
        nsResolver->addNamespaceBinding(n4,ns4);

        const XMLCh *n3 = XMLString::transcode("xsi");
        const XMLCh *ns3 =
XMLString::transcode("http://www.w3.org/2001/XMLSchema-instance";);
        nsResolver->addNamespaceBinding(n3,ns3);
 }
XercesConfiguration xercesconfig;

 XQillaConfiguration* config= xercesconfig::createNode (document, const
DynamicContext *context);


DynamicContext* context=xqilla.createContext(XQilla::UPDATE,config);
     AutoDelete<XQQuery> query(xqilla.parse(X("insert node
<PSE:clAgentFileTransferProtocol>20</PSE:clAgentFileTransferProtocol> after
foo:ConfigDataFile/foo:configData/PSE:PSE/PSE:mclbSrvLoginLocalUserTable/PSE:
mclbSrvLoginLocalUserEntry[@
mclbSrvLoginLocalUserName=\"wimax\"]/PSE:mclbSrvLoginLocalUserPassword")));
   /* AutoDelete<DynamicContext>
context(query->createDynamicContext(document));*/
     Result result = query->execute(context);

     Item::Ptr item;
    while(item = result->next(context)) {
        std::cout << UTF8(item->asString(context)) << std::endl;
    }
xqillaPlatformUtils::terminate();
    return 0;
}

Thanks in Advance
Deepa


The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain proprietary, confidential or privileged information. If you are not
the intended recipient, you should not disseminate, distribute or copy this
e-mail. Please notify the sender immediately and destroy all copies of this
message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should
check this email and any attachments for the presence of viruses. The company
accepts no liability for any damage caused by any virus transmitted by this
email.

www.wipro.com

Current Thread