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/18 22:16:17 UTC

FW: Parsing in a No-File condition generates a Fatal Error, Line: 0, Column: 0

Is there anyone who can provide me with some information on this topic.  Any
help would be greatly appreciated.

Thanks, Joe.

> -----Original Message-----
> From:	Elvin, Joe 
> Sent:	Monday, July 17, 2000 10:07 AM
> To:	'xerces-c-dev@xml.apache.org'
> Subject:	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
> 

Re: Parsing in a No-File condition generates a Fatal Error, Line: 0, Column: 0

Posted by Dean Roddey <dr...@charmedquark.com>.
If you get any fatal errors, you probably shouldn't make any attempt to mess
with the DOM tree that resulted. Are you saying that, if you try to parse a
file that isn't there, that it would corrupt memory without doing anything
else? Reduce it to the mimimum situation in which it occurs. If you can't
reduce it, it might be bugs in your app. If you can, then it will be easier
to figure out why.

--------------------------
Dean Roddey
The CIDLib C++ Frameworks
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com

"You young, and you gotcha health. Whatchoo wanna job fer?"


----- Original Message -----
From: "Elvin, Joe" <el...@cytometrics.com>
To: <xe...@xml.apache.org>
Sent: Tuesday, July 18, 2000 1:16 PM
Subject: FW: Parsing in a No-File condition generates a Fatal Error, Line:
0, Column: 0


> Is there anyone who can provide me with some information on this topic.
Any
> help would be greatly appreciated.
>
> Thanks, Joe.
>
> > -----Original Message-----
> > From: Elvin, Joe
> > Sent: Monday, July 17, 2000 10:07 AM
> > To: 'xerces-c-dev@xml.apache.org'
> > Subject: 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
> >      {
> >          file://initiates the parser; reads the file, converts from UTF8
> >          file://(or whatever format the file has) into UTF16,
> >          file://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
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>