Unless you really need to use the Xerces DOM, you should avoid it. Here's
a much simpler version without it:
XalanTranformer::intialize();
{
XalanTransformer theTransformer;
int theResult =
theTransformer.transform("foo.xml","foo.xsl","foo.out");
cout << "theResult is: " << theResult ;
}
XalanTransformer::terminate();
If you really need to use the Xerces DOM, see the ParsedSourceWrappers
sample, or this usage pattern:
http://xml.apache.org/xalan-c/usagepatterns.html#xercesdomwrapperparsedsource
Dave
Ashay
<[EMAIL PROTECTED] To:
xalan-c-users@xml.apache.org
.com> cc: (bcc: David N
Bertoni/Cambridge/IBM)
Subject: problem with XSLT
tranformation using Xalan
04/22/2003 04:32
AM
Hi,
I am very new to Xerces and Xalan.
I am using Xerces 2.1.0 and Xalan 1.4.0.
Based on one of the examples given on the Apache site, I wrote the below
given simple code and got the following error message while transforming a
XalanDocument.
I am getting -2 as a result of XalanTransformer::tranform() method.
Error msg:
Fatal Error at (file <unknown>, line 0, column 0): An exception occurred!
Type:RuntimeException, Message:The primary document entity could not be
opened. Id={null}
theResult = -2
Could someone give me pointers as to why this error is caused. A speedy
reply would be highly appreciated.
Thanks in advance.
The code:
**************************************************************************
// Use the Xerces DOM parser to create a DOM_Document.
#include <parsers/DOMParser.hpp>
#include <dom/DOM_Node.hpp>
DOMParser theParser;
// You MUST instruct the Xerces DOMParser NOT to create a DOM_XMLDecNode
// in the DOM to represent the XML declaration. See "Limitations" below.
DOMParser::setToCreateXMLDeclTypeNode(false);
theParser.parse("foo.xml");
const DOM_Document theDOM = theParser.getDocument();
// Set up a XercesParserLiaison and use it to wrap the DOM_Document
// in a XalanDocument.
XercesDOMSupport theDOMSupport;
XercesParserLiaison theParserLiaison(theDOMSupport);
XalanDocument* theDoc = theParserLiaison.createDocument(theDOM);
// Use the XalanDocument to create an XSLTInputSource object, which
// you can then use in a transformation.
XSLTInputSource theInputSource(theDoc);
XSLTInputSource theXSLInput("foo.xsl");
XSLTResultTarget theOutput("foo.out");
XalanTranformer::intialize();
XalanTransformer theTransformer
int theResult =
theTransformer.transform(theInputSource,theXSLInput,theOutput);
cout << "theresult is: " << theResult ;
****************************************************************************
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.