$)C
In the first case, Xalan should be throwing an exception, but the code is
only returning 0. That operation is not supported by our wrapper around
the Xerces DOM, as it's impossible to support correctly. I've updated the
code so it will throw the exception in the future.
In the second case, whenever you make a modification to the underlying
Xerces document, you must destory and rebuild the entire wrapper. See
XercesDocumentBridge::rebuildBridge(). This is necessary because the
wrapper optimizes for read access, since that's what Xalan needs.
If you plan on doing a lot of modifications, or other DOM calls, you should
really make those calls through the Xerces interfaces rather than through
Xalan's. The Xalan wrapper is designed for transforming the Xerces DOM.
Dave
[EMAIL PROTECTED]
<[EMAIL PROTECTED] To:
<[email protected]>
c.kr> cc: (bcc: David N
Bertoni/Cambridge/IBM)
Subject: Some problem with
XalanElement::getElementsByTagName(..)
05/29/2002 05:49
AM
I have some problem with using XalanElement::getElementByTagName(..).
It returns NULL although having nodes.
And another problem is below.
My code is like this ;
---------------------------------------
void PrintXalanDOM(XalanNode* theNode)
{
ASSERT(theNode) ;
XalanStdOutputStream theStream(cout);
XalanOutputStreamPrintWriter thePrintWriter(theStream);
FormatterToXML theFormatter(thePrintWriter);
FormatterTreeWalker theWalker(theFormatter);
// Don't write a header...
theFormatter.setShouldWriteXMLHeader(false);
// It's required that we do this...
theFormatter.startDocument();
theWalker.traverseSubtree(theNode);
// It's required that we do this...
theFormatter.endDocument();
}
void main()
{
// initialize Xerces & Xalan
....
// Parse the document by XercesDOMSupport &
XercesParserLiaison, and get XalanDocument* doc
....
XalanElement* root = doc->getDocumentElement() ;
PrintXalanDOM(root) ; // print a source document, no problem
XalanNodeList* nl = root->getElementsByTagName(XalanDOMString
("*")) ; // <-- Problem
assert(nl != NULL) ; // nl is NULL, so assertion failure!!
....
XalanElement* element = root->createElement(XalanDOMString
("Test")) ;
root->appendChild(element) ;
PrintXalanDOM(root) ; // <-- Problem (print a source document
not a changed document)
....
}