hi Alberto

I tried your query, but it was also corrupt. I load the xml dom from the mem 
(because in future the xml comes from a socket), and then i execute the simple 
"/test/b" query

 
    parser = new XercesDOMParser();
    parser->setValidationScheme(XercesDOMParser::Val_Auto);
    parser->setDoNamespaces(true);
    parser->setDoSchema(false);
    parser->setValidationSchemaFullChecking(false);
    parser->setCreateEntityReferenceNodes(false);


                std::string xml("\
<test>\
      <b b1n='b1'> some b1 text\
    </b>\
    <b b2n='b2'>some b2 text\
    </b>\
        <a url='test.xml' name='aaaa'/>\
</test>\
");

 memBufIS = new MemBufInputSource
 (
        (const XMLByte*)xml.c_str()
        , xml.length()
                , "somedoc"
        , false
 );


 try
    {
                parser->parse(*memBufIS);
    }
    catch (const OutOfMemoryException&)
    {
                cout<<"OutOfMemoryException"<<endl;
    }
    catch (const XMLException& e)
    {
                cout << "XMLException" << endl;
    }
        
    catch (...)
    {
                cout << "some unnown exception" << endl;
    }
        root = parser->getDocument()->getFirstChild();
        ((DOMDocument*)parser->getDocument())->setDocumentURI(0);


        XercesConfiguration xercesConf;
        XQillaConfiguration *conf = &xercesConf;
        XQilla xqilla;
        int language = XQilla::XQUERY;
        language |= XQilla::UPDATE;
        Janitor<DynamicContext> contextGuard 
                (xqilla.createContext((XQilla::Language)language, conf));
        DynamicContext *context = contextGuard.get();

        context->setXPath1CompatibilityMode(false);  
        

try{
        XQQuery *query = xqilla.parse(
                X("declare revalidation skip;/test/b"
                ,contextGuard.release()
                        );
        Janitor<DynamicContext> dynamic_context(query->createDynamicContext());
        Node::Ptr node = xercesConf.createNode(root,dynamic_context.get());
        dynamic_context->setContextItem(node.get());
    dynamic_context->setContextPosition(1);
    dynamic_context->setContextSize(1);
        
   memtarget = new MemBufFormatTarget(0, 
                      dynamic_context->getMemoryManager());
   EventSerializer writer("UTF-8", "1.1", memtarget,  
            dynamic_context->getMemoryManager());
   writer.addNewlines(true);
   NSFixupFilter nsfilter(&writer, dynamic_context->getMemoryManager());
   query->execute(&nsfilter, dynamic_context.get());
   }
  catch(XQException &e) {}

        int count = memtarget->getLen()*sizeof(XMLByte);
        result = new string((char*)memtarget->getRawBuffer(),
                                        count);
        cout << "length :" << count << endl;
        cout <<  result << endl;


Sorry for little bit chaotic code (May not work by copy&pasting, because it is 
only a part of my testing programm ;)
My version of XQilla is 2.0.0, do you think i have to upgrade?

greetings
  Affe


-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger

Reply via email to