Title: RE: Convert Xalan Document to Xerces

Hi Dave,

Thanks for the response, It helped me to proceed one step further.
I searched in the mailing list to understand few more things.

Now I am facing a new problem , the mapNode always returns some hexadecimal value. Should I use some data type conversion ?

Input
<MAIN>
        <Name>
                <Skill>Praveen</Skill>
                <Level>0000</Level>
        </Name>
        <Name1>
                <Skill>Prashanth</Skill>
                <Level>1111</Level>
        </Name1>
        <Name2>
                <Skill>Jaya</Skill>
                <Level>2222</Level>
        </Name2>
        <Name3>
                <Skill>Asha</Skill>
                <Level>3333</Level>
        </Name3>
</MAIN>
Xpath given is = /MAIN/Name/Level
Here is code snippet
                const DOMDocument*   Domdoc = theLiaisonPtr->mapToXercesDocument(theDocumentPtr);
              
                XalanDocument *Xalandoc = theLiaisonPtr->createDocument(Domdoc,false,true);           
                if ( Xalandoc == NULL ) {
                        cerr << "Xalandoc doc is NULL"  << endl;
                                exit(1);
                }

                XalanNode * root_context_node = Xalandoc;

                XalanElement *namespace_node =Xalandoc->getDocumentElement();

                const XalanDOMString _expression_(inXPath.data());

                XPathEvaluator evaluator;

                XalanNode* found = evaluator.selectSingleNode(
                                             (*theDOMSupportPtr),
                                             root_context_node,
                                             _expression_.c_str(),
                                             namespace_node);
                if (found) {

                        XercesDocumentWrapper *xerces_document_wrapper =
                        theLiaisonPtr->mapDocumentToWrapper(Xalandoc);

                        const DOMNode * target =(const DOMNode *) xerces_document_wrapper->mapNode(found);
              
                                cout << "Node Name = " << target->getNodeName() << endl;
                            cout << "Node Value = " << target->getNodeValue() << endl;
                        cout << "Node URI = " << target->getNamespaceURI() << endl;
                          cout << "Node Prefix = " << target->getPrefix() << endl;
                          cout << "Node LocalName = " << target->getLocalName() << endl;
                          cout << "Node Type = " << target->getNodeType() << endl;
                }

The output I get is
Node Name = 3a865c
Node Value = 0
Node URI = 0
Node Prefix = 0
Node LocalName = 0
Node Type = 1

Please do help me, my ultimate target is to add new node to the "found" XalanNode.
Please hint me how to do these ?
1. How to add a new Node to "found" XalanNode ? I searched in all the mailing list without success.
2. How to rebuild the Wrapper after modification ?


Thanks

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 16, 2005 10:36 PM
To: [email protected]
Subject: Re: Convert Xalan Document to Xerces

> XercesDOMSupport     domSupport;
> XercesParserLiaison   parserLiaison(domSupport);
> const DOMDocument*   Domdoc =
parserLiaison.mapToXercesDocument(theDocument);
> if ( Domdoc == NULL ) {
>     cerr << "Domdoc  is NULL"  << endl; }

It looks like you've create a XercesParserLiaison instance in order to recover the underlying Xerces DOMDocument from an instance you've created with XalanSourceTreeParserLiaison.  Since there is no underlying DOMDocument, it's not surprising it returns a null pointer.

If you really want to work the Xerces-C DOM, then use a XercesParserLiaison instance instead of a XalanSourceTreeParserLiaison.

However, you should be aware that performance will suffer.  If you intend to modify the DOMDocument and use it again with Xalan-C, you must start with a Xerces DOMDocument and use the XercesParserLiaison to wrap it for use with Xalan-C.  There is some information regarding this in the documentation, and you can search the mail archive for more information.

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Confidentiality Notice

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 confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately
and destroy all copies of this message and any attachments.

Reply via email to