/**
* Creates a compiled stylesheet. The input source can be
* a file name, a stream or a root node. The XalanTransformer
* instance owns the XalanCompiledStylesheet instance and will
* delete it when the XalanTransformer instance goes out of scope,
* or you explicitly call destroyStylesheet(). You must not delete
* the instance yourself.
*
* @param theStylesheetSource input source
* @param theCompiledStylesheet a reference to a pointer to a
XalanCompileStylesheet.
* @return 0 for success
*/
int
compileStylesheet(
const XSLTInputSource& theStylesheetSource,
const XalanCompiledStylesheet*& theCompiledStylesheet);
/**
* Parse a source XML document. The input source can be
* a file name, a stream or a root node. The XalanTransformer
* instance owns the XalanParsedSource instance and will
* delete it when the XalanTransformer instance goes out of scope,
* or you explicitly call destroyParsedSource(). You must not
* delete the instance yourself.
*
* @param theInputSource input source
* @param theParsedSource a reference to a pointer to a
XalanParsedSource.
* @param useXercesDOM input use default or xerces dom source tree
* @return 0 for success
*/
int
parseSource(
const XSLTInputSource& theInputSource,
const XalanParsedSource*& theParsedSource,
bool useXercesDOM = false);
I don't know how this could be more clear. If you create parsed source
instances and compiled stylesheets using an instance of XalanTransformer,
they will be destroyed when that instance goes out of scope. If you create
your own instances, then they will exist for as long as you allow them to
exist. There's no magic here -- you have all of the source code as
documentation, and the source code for compileStylesheet() and parseSource
() is not very complex. You can easily duplicate it in your own code, if
you want to create factories for your own source and stylesheet instances.
You can also use XalanTransformer instances as factories, without even
using them to do transformations. This is what Tests/ThreadTest does.
There is a great deal of documentation that goes along with the APIs. I
encourage you to read it, and give us feedback on whether or not it's
clear. You should also consider the source code as part of the
documentation -- if you don't use it, you're giving up one of the major
benefits of using open source software.
As far as what the most appropriate result for your tranformation -- that's
a difficult question, since you've not really given any detail about what
"further processing" will do. Serialized XML is usually the fastest to
generate, but may be inefficient if you will do more DOM manipulation later
on. If you're planning on a chain of XSLT transformations, and you will
not need to modify the intermediate results, then you can use an instance
of Xalan's source tree as a target, which will give you the most efficient
input for the next transform. Otherwise, you should probably use DOM,
although it will be much, much slower. Often, it's faster to generate
serialized XML and parse the result back into a DOM instance. You'll have
to do your own performance testing to really know what the best approach
is.
If your input data will always first be transformed, then you should build
instances of Xalan's source tree, which you can do through a
XalanDocumentBuilder instance and SAX events. There is a sample which
shows how to use this class.
Dave
wolfgang.sche
[EMAIL PROTECTED] To:
[email protected]
cc: (bcc: David N
Bertoni/CAM/Lotus)
01/27/2002 Subject: Livecycle of Xalan
documents (fragments) and nodes
08:38 AM
Hi everybody!
I'm new to xalan (and xerces) and am looking for some information on the
livecycle of Xalan documents (fragments) and nodes.
I haven't found any documentation on the livecycle of Xalan
Documents/Nodes.
I'm developing a program that periodically collects data of arbitrary type.
I would like to use XML as data format as it is flexible and the collected
data eventually gets transformed several times.
Usage scenario:
(best viewed with fixed-sized font)
THREAD1 THREAD2
------------------- -------------------
| datacollector | | dataprocessor |
------------------- -------------------
| |
collect data |
| |
create xml |
representation |<-----------
| ----------- | |
----------->| queue | | |
----------- | |
| | |
----------->get data |
from queue |
| |
transfrom data |
using compiled |
stylesheet |
| |
----------- put data |
| into queue |
| | |
v -------------
-----------
| queue |
-----------
|
V
further
processing
with another
thread...
Is it possible to create a document (fragment), keep it, move it around
and perform an arbitrary number of transformations and destroy it when all
further processing is done or is the newly created document (fragment)
bound
to a specific instance of a xalan class (XalanTransformer/...) and will be
destroyed whenever the instance is destroyed/goes out of scope?
What would be the best container for the generated data: a Xerces (I)DOM
document, a Xalan document (fragments) or a single Xalan node?
And what about compiled stylesheets? Are they bound to a specific instance
of a xalan class or can I create and destroy it whenever I want?
Any help is greatly appreciated.
Many thanks in advance
Wolfgang
--
Wolfgang Schell
[EMAIL PROTECTED]
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net