You should not be using the XalanDocument instance you get from the
XalanDocumentBuilder instance. Right now, the Xalan-C++ output handler is
not compatible with a SAX2 event handler. This will be fixed eventually,
but for now, you'll need to do something like this:
XalanSourceTreeParserLiaison theParserLiaison;
XalanSourceTreeDocument* const theDocument =
theParserLiaison.createXalanSourceTreeDocument();
assert(theDocument != 0);
FormatterToSourceTree theFormatter(theDocument);
// If your output will be generating nodes with namespaces, you'll need
to implement
// a class that derives from PrefixResolver to associate namespace URIs
with prefixes.
// You shouldn't have to do this, as the transformation process should
handle this.
// (we'll be fixing this soon.)
// theFormatter.setPrefixResolver(&prefixResolver);
XSLTResultTarget theResultTarget;
theResultTarget.setDocumentHandler(&theFormatter);
theResult = theXalanTransformer.transform(*theInputBuilder, "foo.xsl",
theResultTarget);
It's on our list of things to do to make this process much simpler. But
for now, this is the best way to do it.
Remember that the resulting document you build will not be mutable by the
normal DOM interfaces. If you need a truly mutable DOM for output, you'll
need to use an instance of the Xerces DOM for output. That's actually
easier:
XercesParserLiaison theXercesParserLiaison;
const XSLTResultTarget
theResultTarget(theXercesParserLiaison.createDOMFactory());
theResult = theXalanTransformer.transform(*theInputBuilder, "foo.xsl",
theResultTarget);
XalanDocument* const theDocument = theResultTarget.getDocument();
Dave
Michael Schultz
<michael@metroso To: [EMAIL PROTECTED]
ul.com> cc:
Sent by: Subject: can't create XalanDocument
output with
[EMAIL PROTECTED] XalanTransformer.transform()
s.ibm.com
12/27/2001 09:28
PM
Please respond
to xalan-dev
I'm trying to use the XalanTransformer::transformer() method to
transform a XalanDocument object that I've created programmatically.
I have no problem creating the document and adding elements to it using
the SAX API, but when I try to transform it, I get a XalanDOMException
with code = NO_MODIFICATION_ALLOWED_ERR
Is it impossible to create a XalanDocument with
XalanTransformer::transformer()?
This is what I've done:
***********************************************************
XMLPlatformUtils::Initialize();
XalanTransformer::initialize();
XalanTransformer theXalanTransformer;
XalanDocumentBuilder* const theInputBuilder =
theXalanTransformer.createDocumentBuilder();
XalanDocumentBuilder* const theOutputBuilder =
theXalanTransformer.createDocumentBuilder();
...
...
//get the SAX2 ContentHandler from the builder and
//build the input document with SAX
...
...
theResult = theXalanTransformer.transform( *theInputBuilder, "foo.xsl",
theOutputBuilder->getDocument());
************************************************************
Thanks for any help...