Vikram A K Gupta wrote:
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
It should not an "unknown" exception, it should be a XalanDOMException. Here's a snippet from the source code:

void
XalanSourceTreeElement::setNodeValue(const XalanDOMString&          /* 
nodeValue */)
{
        throw XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
}


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
    {
    }
Unless the node is a null pointer, and you're not checking for that, I don't know why you're getting an unknown exception. Often, running your code in a debugger will help with determining what's wrong.

However, your approach will not work, as the Xalan-C source tree is not mutable. The typical way to handle this is to either use the Xerces-C source tree with the Xalan-C wrappers, or write an XSLT stylesheet that does the transformation, changing the values as appropriate.

Dave

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

Reply via email to