I thought the Xalan tree was read-only and if you neeeded a modifiable
document you had to use a Xerces. 

-----Original Message-----
From: Vikram A K Gupta [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 01, 2007 4:21 AM
To: [EMAIL PROTECTED]; xalan-c-users@xml.apache.org
Cc: [EMAIL PROTECTED]
Subject: Xalan (with Xerces) - Modify a value at a Node 


Hi All,

Background
- We are developing a generic cross reference task for a middleware
application.
- We will be processing multiple XML formats and the plan is to have a
single instance of the new cross reference task.
- We plan on configuring XPATH rules to extract a value (extraction is
processed by another task and is complete)
- After obtaining the value from the XML, we will do a cross reference
look-up via a database and then look to repopulate the new value back in
the msg via the original XPATH rule,

The issue we are having is around the re-insertion of the value.
Approach that we are using:
               1) XercesLiaisonParser to parse message
               2) XPathEvaluator to identify a particular node
               3) XalanNode::setNodeValue to modify the value But we are
getting 'Unknown exception' when i try to do XalanNode::setNodeValue.
Any pointers to resolve it ?
Following is code snippet but it is failing with the UNKNOWN EXCEPTION

Any clue how to resolve it and also an alternative approach to achieve
the requirement !!

try{

    // We'll use these to parse the XML file.
    XercesDOMSupport theDOMSupport;
    XercesParserLiaison theLiaison(theDOMSupport);

    // Create an input source...
    const MemBufInputSource theInputSource( reinterpret_cast<const
XMLByte*>(message.c_str()),
    XalanDOMString::length(message.c_str()),
    "SourceXML",
    false );

    // Parse the XML Stream
    XalanDocument* const theDocument =
theLiaison.parseXMLStream(theInputSource);
    XPathEvaluator      theEvaluator;
    XalanNode* const theContextNode = theDocument->getDocumentElement();

    //Retrieve the XalanNode for the compiled XPath
    XalanNode* pXalanNode, *pConstNode = NULL;
    pConstNode =  theEvaluator.selectSingleNode (theDOMSupport,
    theContextNode,
    *m_compiledXPATH);

    XalanDOMString xalanDOMString("NewValue");
    pConstNode->setNodeValue(xalanDOMString);    // UNKNOWN EXCEPTION
BEING THROWN

    }
    catch(const XalanDOMException& xde)
    {
    }
    catch(const DOMException& de)
    {
    }
    catch (...) // UNKNOWN EXCEPTION BEING CAUGHT HERE
    {
    }

Thanks for helping !!
Vikram

**************** CAUTION - Disclaimer ***************** This e-mail
contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the
use of the addressee(s). If you are not the intended recipient, please
notify the sender by e-mail and delete the original message. Further,
you are not to copy, disclose, or distribute this e-mail or its contents
to any other person and any such actions are unlawful. This e-mail may
contain viruses. Infosys has taken every reasonable precaution to
minimize this risk, but is not liable for any damage you may sustain as
a result of any virus in this e-mail. You should carry out your own
virus checks before opening the e-mail or attachment. Infosys reserves
the right to monitor and review the content of all messages sent to or
from this e-mail address. Messages sent to or from this e-mail address
may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

Reply via email to