You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by wo...@gmx.net on 2002/02/11 19:30:17 UTC
how to create nodes from an external function
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
wolfgang.schell@gmx.net
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net