logo       

RE: Error In Code (Sax Parsing): msg#00081

text.xml.xerces-c.user

Subject: RE: Error In Code (Sax Parsing)


Ok Guys,

Ive sorted It & made my deadline..

Thankyou to everyone who helped

Cheers
Alex


Jesse Pelton wrote:
>
> But your constructor calls loadXML_proj(), so all the code in that
> function is executed while prjLoad is being constructed. This does not
> differ in any significant way from executing the same code in the
> constructor.
>
> -----Original Message-----
> From: appleGuy [mailto:alx.curtis@xxxxxxxxx]
> Sent: Wednesday, December 20, 2006 12:32 PM
> To: c-users@xxxxxxxxxxxxxxxxx
> Subject: RE: Error In Code (Sax Parsing)
>
>
> Ok, Ill see what turns up.
>
> Most (if not all) of the parsing code is not in the constructor. Its in
> a
> seperate function, that is independant of the constructor.
>
> Cheers
> Alex
>
>
> Jesse Pelton wrote:
>>
>> You might want to start by trapping all the exceptions that parse()
> can
>> generate. DOMException, OutOfMemoryException, and (I think)
>> SAXException are all possibilities that you haven't covered. Using
> the
>> getMessage() member to display the exception message may well be
>> revealing.
>>
>> Personally, I'd think twice before implementing a constructor that
> does
>> so much work. Handling exceptions properly in constructors is
>> notoriously difficult, and this one is rife with opportunities for
>> error.
>>
>> -----Original Message-----
>> From: appleGuy [mailto:alx.curtis@xxxxxxxxx]
>> Sent: Wednesday, December 20, 2006 12:05 PM
>> To: c-users@xxxxxxxxxxxxxxxxx
>> Subject: Error In Code (Sax Parsing)
>>
>>
>> Hi,
>>
>> My program generates a runtime error...I went through the debugger &
> it
>> seems to break at the parser->parse(XMLfile)
>>
>> The error is:
>>
>> Debug Error!....this application has requested the runtime to
> terminate
>> in
>> an unusual way
>>
>> The code with problems:
>>
>> #include "prjLoad.h"
>>
>> //DEBUG
>> #include <iostream>
>> using namespace std;
>>
>> //Default Constructor
>> prjLoad::prjLoad(prjHandler *ptr_tmp): prjHandle(ptr_tmp){
>> loadXML_prj("xml_file.xml");
>> }
>>
>> //Destructor
>> prjLoad::~prjLoad(void){
>> //Terminate The Dom Session
>> XMLPlatformUtils::Terminate();
>> }
>>
>> bool prjLoad::loadXML_prj(char *prj_filename){
>> //Start XML Xerces Framework
>> try {
>> XMLPlatformUtils::Initialize();
>> }
>> catch (const XMLException& toCatch) {
>> char* message =
> XMLString::transcode(toCatch.getMessage());
>> cout << "Error during initialization! :\n"
>> << message << "\n";
>> XMLString::release(&message);
>> return false;
>> }
>>
>> //Create New Parser (SAX)
>> SAXParser* parser = new SAXParser();
>>
>> //File Input Validation
>> parser->setDoValidation(true);
>> parser->setDoNamespaces(true);
>>
>> //Create our SAX handler object and install it on the
>> parser (Doc & Error
>> Handler)
>> //Using Project as Handler
>> parser->setDocumentHandler(prjHandle);
>> parser->setErrorHandler(prjHandle);
>>
>> //Load File through Xerces
>> XERCES_STD_QUALIFIER ifstream xmlFileHandle;
>> xmlFileHandle.open(prj_filename);
>>
>> //Load Each Line From File To Array xmlFile
>> bool flag = true;
>> while (flag == true)
>> {
>> char token[1000];
>> //Set array to zeros
>> memset(token,0,sizeof(token));
>>
>> //Sequential Search
>> if(!(xmlFileHandle.eof())){
>> xmlFileHandle.getline(token, sizeof(token));
>>
>> //Check If Line Contains Anything
>> if(!(token))
>> continue;
>> else {
>> //Load into New Derived Variable for
>> overloading & Safety
>> const char *XMLfile = token;
>>
>> //Debug
>> cout << "Parsing: " << XMLfile << endl;
>>
>> //ERROR WIPE -> NEEDS IMPLIMENTING
>>
>> try {
>> parser->parse(XMLfile);
>> }
>> catch(XMLException &e){
>> cout << "ERROR OCCURED" << endl;
>> }
>>
>> }
>>
>>
>> }
>> //ELSE STATEMENT FOR EOF-> Set Flag to false therefore
>> exiting while loop
>> else
>> flag = false;
>>
>>
>> }
>> return true;
>> }
>>
>> Thanks For looking at this its been bugging me for hours
>>
>> Cheers
>> -Alex
>> --
>> View this message in context:
>>
> http://www.nabble.com/Error-In-Code-%28Sax-Parsing%29-tf2860959.html#a79
>> 93779
>> Sent from the Xerces - C - Users mailing list archive at Nabble.com.
>>
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/Error-In-Code-%28Sax-Parsing%29-tf2860959.html#a79
> 94297
> Sent from the Xerces - C - Users mailing list archive at Nabble.com.
>
>
>

--
View this message in context:
http://www.nabble.com/Error-In-Code-%28Sax-Parsing%29-tf2860959.html#a8017526
Sent from the Xerces - C - Users mailing list archive at Nabble.com.




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise