Hiya folks. In the last couple days I've been trying to wrap my head around
the Xalan/Xerces APIs and I've run into some trouble that I can't seem to
get by.
As background, I'm new to these APIs as the XML work I did a couple years
ago was done using MSXML on Windows so I'm quite new to this library. I've
tried looking at as much documentation and samples as I can but alas I have
been unable to locate a clear direction for what I'm trying to do. The
differences between the two libraries DOM models and the fact that the Xalan
api uses the now deprecated Xerces DOM objects has me quite confused as to
what I'm "supposed" to be doing to accomplish my task :)
The basic issue is that I am trying to do some XSL transformations. My
input is an XML string in memory, the stylesheet is in a file on disk, and
I'd like my output to be in memory also (not in a file). I'd prefer DOM
output instead of a string. It's not entirely clear to me on how to do
this.
My initial attempt was to use a std::stringstream object to construct an
XSLTInputSource object but this didn't seem to work at all. Currently I
have some code using the deprecated Xerces API to produce a DOM_Document.
I'm then running that through the ParserLiasion and
XercesDOMWrapperParsedSource objects to get it into the transform. This
seems to work ok as long as the XSLTResultTarget points to a file on disk.
My problem is that as soon as I try to make the output of the transformation
use a XalanDocument it fails. I tried following what the documentation
describes:
XalanTransformer theXalanTransformer;
XercesDOMSupport theDOMSupport;
XercesParserLiaison theParserLiaison(theDOMSupport);
// Produce input and stylesheet InputSources
....
//
XalanDocument* docOut = theParserLiaison.createDocument();
XSLTResultTarget theDOMResultTarget(docOut);
int theResult = theXalanTransformer.transform(parsedSource, stylesheet ,
theDOMResultTarget);
This seems to fail in the transform returning a -4. From inspecting the
code this seems to be some sort of XercesException but there is no
indication as to what the issue is. Remember that this works fine if
theDOMResultTarget is constructed with a simple filename URI such as
"output.xml". Just getting the DOM output doesn't seem to work for me.
For a bit I thought the liaison could only be used once so I made a second
one for making the XalanDocument but that didn't work either.
Am I going about this whole thing the wrong way, making it more difficult
than it needs to be? I would think this would be a fairly common task to
perform and I'm a bit perplexed at the moment.
Thanks for your help!
--
Greg Dunko
Fidelity Investments
603.791.8216
mailto:[EMAIL PROTECTED]