Hi Mark,
1. Chaining such transformations together should fairly straightforward. You need an instance of FormatterToSourceTree (I know, bad name...) for each output stage, which can be passed into the transformation in an XSLTResultTarget instance. How about I write a small sample program that does this?
2. There are several ways I can think of to accomplish what you're trying to do. May other folks have some opinions as well.
The first is to create your own XNodeSet derivation that contains a pointer to the XalanSourceTreeDocument instance. It can then delete the instance in its destructor. I'm actually thinking of implementing a standard way for extension functions to produce node-sets and result tree fragments, and this is probably the way I would go, although I think I would use SAX interfaces instead of the DOM interfaces. Any opinions?
The other is as you've stated: hold all of the instance in the function instance and have it delete them in its destructor. That has several disadvantages. One is that your function is only thread-safe if you synchronize access to this cache. The other is that the instance live until the function instance is destroyed. This is OK if you're using locally installed extension function instances, but is a disaster if you're using one that's globally installed.
Dave
"Mark Weaver" <[EMAIL PROTECTED]>
07/16/2002 11:45 AM | To: "Xalan-C-Users" <[email protected]> cc: (bcc: David N Bertoni/Cambridge/IBM) Subject: dom->dom transformation + returning xml nodes from extensions functions |
Two unrelated questions. The first is that I would like to transform a DOM
into a DOM, the reason for this is that there may be a number of stylesheets
applied to a single input XML document, thus giving a general procedure:
input --styleA--> DOM output #1
DOM output #1 --styleB--> DOM output #2 (...)
DOM output #n --styleZ--> string
currently all of my outputs are strings, but I'm assuming it would be more
efficient to directly output a XalanSourceTreeDocument at each stage to
avoid reparsing the text data. However, i'm having little luck in doing
this, any clues would be much appreciated.
The second question is that I have some extension functions that return
nodesets, containing dynamically generated nodes (these are in fact SQL
lookups). I do this by creating a XalanSourceTreeDocument and adding nodes
onto this, e.g.:
XalanSourceTreeDocument* theDocument = new XalanSourceTreeDocument(1);
XalanSourceTreeElement* sql = theDocument->createElementNode(L"sql",
emptyAttributes, theDocument);
theDocument->appendChildNode(sql);
XPathExecutionContext::BorrowReturnMutableNodeRefList
theNodeList(executionContext);
theNodeList->addNode(theDocument);
return executionContext.getXObjectFactory().createNodeSet(theNodeList);
Now my problem is that this document does not belong to the execution
context, and in fact here it belongs to nothing (and is leaked). Should I
just have the function object cache the generated documents, or is there a
better way of doing this?
Thanks,
Mark
<<inline: graycol.gif>>
<<inline: ecblank.gif>>
<<inline: pic00292.gif>>
