Hi everybody!
I tried to create nodes (element/text) from within an external function but
always get a XalanDOMException with code 9 (i.e. NOT_SUPPORTED_ERR).
My approach was to get the context node's owner document and use it to
create new nodes.
The code roughly looks like this:
MyFunction::execute(XPathExecutionContext& executionContext,
XalanNode* context,
const XObjectPtr arg1,
const XObjectPtr arg2,
const Locator* locator) const
{
typedef
XPathExecutionContext::BorrowReturnMutableNodeRefList
BorrowReturnMutableNodeRefList;
XalanDocument* pDoc = context->getOwnerDocument();
BorrowReturnMutableNodeRefList theResult(executionContext);
pParameterName =
reinterpret_cast<XalanNode*>(pDoc->createTextNode(XalanDOMString("my text
node")));
theResult->addNode(pParameterName);
return executionContext.getXObjectFactory().createNodeSet(theResult);
}
I then had a look at the implementation of the XSLT document() function,
which simply uses the XPathExecutionContext's parseXML() method to read a new
document, so that is not an option here.
My next step was to use a dombuilder to create the nodes I wanted to create
and it actually works. The problem is, that I don't know how to keep track of
memory usage. If I delete the DOM builder right afterwards, the program
crashes (which seems quite logical to me ;-) but if I don't delete it, the
memory
probably won't be freed.
Any help either on how to use a DOMBuilder correctly in this situation or
other suggestions on how to create nodes from within an external function are
greatly appreciated.
Cheers
Wolfgang
--
Wolfgang Schell
[EMAIL PROTECTED]
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net