See:

   http://xml.apache.org/xalan-c/usagepatterns.html#xercesdomwrapperparsedsource

Dave



                                                                                
                                                        
                      FPO Chat                                                  
                                                        
                      <[EMAIL PROTECTED]         To:      
[email protected]                                                    
                      e.de>                    cc:      (bcc: David N 
Bertoni/Cambridge/IBM)                                            
                                               Subject: could'nt transform a 
preparsed xml-file                                         
                      01/30/2003 12:42                                          
                                                        
                      AM                                                        
                                                        
                                                                                
                                                        



Hi

I'm using xalan-c++ version 1.4. I could'nt transform a preparsed xml-file.
Is
there a solution of this problem?
 The progam terminates with error:

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}


Here is the code:

#include <Include/PlatformDefinitions.hpp>
#include <cassert>

#include <xercesc/dom/deprecated/DOMParser.hpp>
#include <xercesc/util/PlatformUtils.hpp>

#include <XercesParserLiaison/XercesParserLiaison.hpp>
#include <XercesParserLiaison/XercesDOMSupport.hpp>

#include <XalanTransformer/XalanTransformer.hpp>
#include <XalanTransformer/XalanSourceTreeWrapperParsedSource.hpp>

int main(int argc, const char* argv[]) {

    int     theResult = -1;

    try {
        XMLPlatformUtils::Initialize();
        XalanTransformer::initialize();
    }
    catch (const XMLException& toCatch) {
         cerr << "Error during initialization! Message:\n"
              << toCatch.getMessage() << endl;
         return 1;
    }

    try {
        XalanTransformer    theTransformer;

        XalanTransformer    theXalanTransformer;

        DOMParser parser;
        parser.setToCreateXMLDeclTypeNode(false);
        try {
            parser.parse("afp.xml");
        }
        catch (const XMLException& e) {
            cerr << "\nError during parsing memory stream:\n"
                 << "Exception message is:  \n"
                 << e.getMessage() << "\n" << endl;
            return 4;
        }
        const DOM_Document      theDOM = parser.getDocument();
        XercesDOMSupport        theDOMSupport;
        XercesParserLiaison     theParserLiaison(theDOMSupport);
        XalanDocument *theDoc = theParserLiaison.createDocument(theDOM);
        XSLTInputSource         theInputSource(theDoc);

        theResult = theXalanTransformer.transform(theInputSource,
                                                "afp.xsl", "out.xml");
    }
    catch(...) {
        cerr << "An unknown error occurred!" << endl;
    }
}

--
Thomas Schletter
CVD, Chemnitz, Germany
+49-371-656 680
[EMAIL PROTECTED]



Reply via email to