You just looked at the wrong usage pattern:
http://xml.apache.org/xalan-c/usagepatterns.
html#xercesdomwrapperparsedsource
XalanTransformer is a fairly new class, so the old usage pattern applies to
the old interfaces.
By the way, you _must_ scope the Xerces and Xalan class instances properly:
1 XMLPlatformUtils::Initialize();
2
3 XalanTransformer::initialize();
4
4a {
5 DOMParser theParser;
...
}
Otherwise, you risk disaster.
Dave
"McNally, David"
<David. To:
"'[email protected]'" <[email protected]>
[EMAIL PROTECTED] cc: (bcc: David N
Bertoni/Cambridge/IBM)
com> Subject: Transforming a Xerces
DOM with Xalan
07/29/2002 07:57
AM
Apologies if this is a FAQ - but I couldn't find anything that exactly
addressed my problem in the archives or docs.
I want to take a DOM document from DOMParser and transform it with Xalan.
The Xalan basic usage patterns describe how to do this - but I couldn't get
that code to compile. With some minor changes, I ended up with this:
1 XMLPlatformUtils::Initialize();
2
3 XalanTransformer::initialize();
4
5 DOMParser theParser;
6 theParser.setToCreateXMLDeclTypeNode(false);
7 theParser.parse(argv[1]);
8 DOM_Document theDOM = theParser.getDocument();
9
10 XercesDOMSupport theDOMSupport;
11 XercesParserLiaison
theParserLiaison(theDOMSupport);
12 XalanDocument* theDoc =
theParserLiaison.createDocument(theDOM);
13
14 XSLTInputSource theInputSource(theDoc);
15
16 XalanTransformer theXalanTransformer;
17
18 theResult = theXalanTransformer.
transform(theInputSource,
"stylesheet.xsl", cout);
But I get the error:
error C2664: '__thiscall XSLTInputSource::XSLTInputSource(const unsigned
short *)' : cannot convert parameter 1 from 'class XalanDocument *' to
'const unsigned short *'
Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast
Looking in the apidocs I don't see 'const unsigned short *' as a possible
constructor, so I don't know what's going on. I tried casting like this:
14 XSLTInputSource theInputSource((XalanNode*)
theDoc);
which compiled, but it fails at runtime with
Fatal Error at (file , line 0, column 0): An exception occured!
Type:RuntimeExce
ption, Message:The primary document entity could not be opened. Id={null}
Error:
An exception occured! Type:RuntimeException, Message:The primary document
entity
could not be opened. Id={null}
Can anyone spot my error, or point me to the right place in the
documentation/faq?
Thanks,
David