Sami Islam wrote:
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?
in the same faq they say that:
"The Xalan DOM implementation is highly optimised for
transformations. However, whilst you can build documents in the Xalan
DOM, subsequent modification will not work. The Xalan DOM is designed
to be either an input or an output from a transformation, not as a
general DOM implementation.
So in cases where you want to simply transform documents using
Xalan, using the internal DOM implementation is the best approach."
i'm not able to say why they implemented in such way (i mean what
they provide the setNodeValue) coz i haven't implemented neither
designed this library, i can't say more explanations that forward to
you what i've readed or what i've done, sorry.
perhaps someone could say why
Francesc
---------------------------------------
Francesc Guim Bernat
http://francesc.guim.net
--
Thanks,
Sami
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
|