You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Elvin, Joe" <el...@cytometrics.com> on 2000/07/17 16:07:22 UTC
Parsing in a No-File condition generates a Fatal Error, Line: 0,
Column: 0
Basically I am trying to load an xml document into memory. However, the
file does not always exist. Therefore in some cases the code snippets below
are executed in a no-file condition. When run in a no-file condition I get
the fatal error listed in the e-mail subject line and memory appears to
become corrupted. Does the parser require that the file exist prior to
parsing it ? I have included some code below and listed it in the order
that it is executed for a given xml file.
* Execute XMLPlatformUtils::Initialize if the private static object
member m_platformInit is false.
* Validate the xml model
* Create the path for the xml file if necessary.
* Create a DOM document in memory
// If in BADMODEL state, bail out
if (m_error != XMLERR_BADMODEL)
{
// Create new document
m_doc = DOM_Document::createDocument();
// Create new root element
m_cur = m_doc.createElement(m_model[0].name);
// Set its type to 0
m_cur.setUserData(0);
// Put root element into document
m_doc.appendChild(m_cur);
// And that's it
m_error = XMLERR_NONE;
}
return m_error;
* Parse the xml file.
DTDValidator* pValidator = new DTDValidator;
XMLFileParser parser(pValidator);
// Set my document handler on the parser
XMLFileHandler handler(*this);
parser.setDocumentHandler(&handler);
// This is dummy, XMLFileHandler doesn't implement
error-handling logic.
// But this forces the parser to register itself as an
error-handler with
// XMLScanner, and my derivation of SAXParser does
handle errors
parser.setErrorHandler(&handler);
// Set doctype handler. The only purpose is to see if
the document has any
// doctype declaration at all. We start as
non-validating parser, and switch
// to validating when doctype declaration is
encountered
XMLFileDocTypeHandler docTypeHandler(parser);
pValidator->setDocTypeHandler(&docTypeHandler);
try
{
//initiates the parser; reads the file, converts
from UTF8
//(or whatever format the file has) into UTF16,
//and creates the tree in RAM.
parser.parse(fileName.Text()); // the param is a
const char*
}
Thanks, Joe.
Richard H. Elvin (Joe) Cytometrics, Inc.
Sr. Software Engineer One Independence Mall
E-Mail: elvin@cytometrics.com 615 Chestnut Street
Phone: (215) 574-7341 Seventeenth Floor
Fax: (215) 574-7099 Philadelphia, Pa. 19106