You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Karpinski, Charles" <ch...@jnli.com> on 2003/07/15 21:11:27 UTC

C++ XML Parsing error "the primary document entity could not be o pened" - problem when parsing mult files

Hello,

I am a C++ programmer who is new to XML parsing, so please bear with me.  We

have set up a parsing method that works great when there is only one input 
file, but when we try to parse a second file (as we are looping thru all the

files in the directory), the follow error is generated upon calling:

XalanDocument*  l_XalanDocument	= l_ParserLiaison.parseXMLStream
(l_FileInputSource, l_identifier)

Fatal Error at (file <unknown>, line 0, 
column 0): An exception occurred! Type:RuntimeException, Message:The primary

document entity could not be opened. I
d=C:\Program Files\Common Files\System\Mapi\1033
\NT\AN\20030508140024258JNBATCH0002TXN_JNT2.XML

The guts of the function are pasted in below.

In the constructor of the class I am calling the following:

		XMLPlatformUtils::Initialize();
		
		XPathEvaluator::initialize();

		XPathEnvSupportDefault::initialize();

		XPath::initialize();

and I am calling the terminates for the above in the destructor.  I have
found that if I process all the files without letting the parsing class go
out of scope and within one set of the init/terminate calls, it works to
process multiple files.  However, when the routine gets called again for the
next files (the exe and dll's remain loaded during this time), it blows up
on the first file with the above error.  It is evident that something static
or global is not being cleaned up properly.  

I have tried for several days to resolve the problem, with no success.  Not 
sure if this is a bug, or a problem with our methodology.  Any help would be

appreciated.  Hopefully it is just something stupid that I am doing or not 
doing.

Thanks,
Charles Karpinski


XalanSourceTreeDOMSupport l_SourceDOMSupport;
			
l_SourceDOMSupport.reset();
			
XalanSourceTreeParserLiaison l_ParserLiaison(l_SourceDOMSupport);
			
l_ParserLiaison.reset();

// Define Xalan/XML Resources to be used later
XPathEvaluator			l_XPathEvaluator;
XPathEnvSupportDefault		l_XPathEnvSupport;
l_XPathEnvSupport.reset();
XObjectFactoryDefault		l_XObjectFactory;
l_XObjectFactory.reset();
XPathExecutionContextDefault 	l_ExecutionContext(l_XPathEnvSupport,

						l_SourceDOMSupport,
						l_XObjectFactory
						);
l_ExecutionContext.reset();

XPathFactoryDefault		l_XPathFactory;
l_XPathFactory.reset();

XPathProcessorImpl		l_XPathProcessor;
XObjectPtr			l_XPathObject;

l_ParserLiaison.setExternalSchemaLocation(c_wstr(XalanDOMString(m_ExternalSc
hemaLocation.c_str())));
// tell the parser liaison not to include ignorable whitespace
l_ParserLiaison.setIncludeIgnorableWhitespace(false);
// Combine the support and the liaison together
l_SourceDOMSupport.setParserLiaison(&l_ParserLiaison);

// Open file
LocalFileInputSource
l_FileInputSource(c_wstr(XalanDOMString(m_sVendorFileName.c_str())));

XalanDOMString l_identifier; // for reporting of errors
			
XalanDocument*  l_XalanDocument	=
l_ParserLiaison.parseXMLStream(l_FileInputSource, l_identifier);