Title: Nachricht
Hello,
I found out where I get the exception from. It is because I am using the Evaluator with an XObjectPtr in scope which I am not allowed to do.
 
So you are saying there isn't any easy way to set the Node Value using Xalan. Why is there a setNodeValue( ) present then?
 
Thanks,
Sami
-----Urspr�ngliche Nachricht-----
Von: Francesc Guim Bernat [mailto:[EMAIL PROTECTED]
Gesendet: Mittwoch, 19. Mai 2004 14:21
An: [email protected]
Betreff: Re: How to set Node Value?



Sami Islam wrote:

Hello,
I evaluate an _expression_ and check the result to see if the node has a value.
When the value is empty i.e. "" then I would like to insert a default value for the particular node.
My code:
**************************************************************************************************
const XObjectPtr        theResult(theEvaluator.evaluate(theDOMSupport,
                                                          theDocument,
                                                        XalanDOMString("/doc/[EMAIL PROTECTED]'Tom']").c_str(),
                                                        thePrefixResolver));
assert(theResult.null() == false);

const CharVectorType localResultVec(TranscodeToLocalCodePage(theResult->str()));

if(strcmp("", (c_str(localResultVec))) == 0)
{
        XalanNode* const        theEmptyNode = theEvaluator.selectSingleNode(
                                                        theDOMSupport,
                                                        theDocument,
                                                        XalanDOMString("/doc/[EMAIL PROTECTED]'Tom']").c_str(),
                                                        thePrefixResolver);
                                               
        XalanDOMString testString("Hello");
        theEmptyNode->setNodeValue(testString);
}
**************************************************************************************************
I get a assertion failed error on m_referenceCount == 0 coming from file XalanReferenceCountedObject.cpp.

What am I doing wrong? How can I set the value of the node when it is empty?

on the xalan FAQ web page they say that if u wanna modifiy a DOM document you should use Xerces instead of Xalan:

"In cases where you want to modify the DOM document on the fly, you should use the Xerces DOM as the base document. You can wrap the Xerces DOM in a wrapper (see passing in a Xerces DOM) to then use as an input to a Xalan transformation. Alternatively you can output the result of a transformation to a Xerces DOM document (see working with DOM input and output). In either case, the Xerces document can be freely modified. However, after you modify the document, you need to re-build the wrapper so that any changes are replicated in the Xalan wrappers."

the sample
XPathWrapper.cpp that is provided in the Xalan project show how to use this wrapper. 

Nevertheless the error that you are getting doesn't seem to be related to the setNodeValue call. In which statment is the exception triggered ?

---------------------------------------
Francesc Guim Bernat
http://francesc.guim.net --


Francesc

Regards,

Sami

Reply via email to