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 Monica Lau <ml...@yahoo.com> on 2004/03/30 03:19:16 UTC

No Parsing Errors?!

Hi all,

I am very new to XML as well as to the Xerces XML
parser.  I have a very simple program below to parse
the XML string: "<hello>abc</world>"  When I run this
program, the program runs smoothly, and I don't get
any error messages at all.  I'm not sure what I'm
doing wrong...  Please help -- thanks for your time!

Regards,
Monica
  

#include <iostream.h>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/ParseException.hpp>
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/framework/MemBufInputSource.hpp>

int main()
{
   try
   {
      XMLPlatformUtils::Initialize();
   }
   catch (const XMLException &error)
   {
      char *msg =
XMLString::transcode(error.getMessage());
      cout << "Error during initialization: " << msg
<< endl;
      return -1;
   }

   XercesDOMParser parser;
   parser.setDoSchema(false);
  
parser.setValidationScheme(XercesDOMParser::Val_Never);

   // Parse XML file.
   char *myXMLStr = "<hello>abc</world>";

   try
   {
      MemBufInputSource mbis( (const XMLByte
*)myXMLStr, strlen(myXMLStr), "dummy", false);
      parser.parse(mbis);
   }
   catch(const XMLException &error)
   {
      char *msg =
XMLString::transcode(error.getMessage());
      cout << "Error during parsing: " << msg << endl;
      return -1;
   }
   catch (const DOMException &error)
   {
      char *msg = XMLString::transcode(error.msg);
      cout << "Error during parsing: " << msg << endl;
      return -1;
   }
   catch(...)
   {
      cout << "Unexpected exception during parsing."
<< endl;
      return -1;
   }

   return 0;
}


__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: No Parsing Errors?!

Posted by Monica Lau <ml...@yahoo.com>.
Thanks All for your help!  As suggested, I followed
the DOMTreeErrorReporter code in the DOMPrint sample,
and it worked!

Thanks again,
Monica  


--- Ashay Shende <as...@cisco.com> wrote:
> Hi, If you are using XercesDOMParser, I think you
> will have to inherit from
> ErrorHandler class.
> You can then implement the fatalError() method and
> display the line number
> etc where the error occured.
> 
> Hope this helps.
> 
> -----Original Message-----
> From: Monica Lau [mailto:mllau2004@yahoo.com]
> Sent: Tuesday, March 30, 2004 6:49 AM
> To: xerces-c-dev@xml.apache.org
> Subject: No Parsing Errors?!
> 
> 
> Hi all,
> 
> I am very new to XML as well as to the Xerces XML
> parser.  I have a very simple program below to parse
> the XML string: "<hello>abc</world>"  When I run
> this
> program, the program runs smoothly, and I don't get
> any error messages at all.  I'm not sure what I'm
> doing wrong...  Please help -- thanks for your time!
> 
> Regards,
> Monica
> 
> 
> #include <iostream.h>
> #include <xercesc/parsers/XercesDOMParser.hpp>
> #include <xercesc/dom/DOM.hpp>
> #include <xercesc/util/XMLString.hpp>
> #include <xercesc/util/PlatformUtils.hpp>
> #include <xercesc/util/XercesDefs.hpp>
> #include <xercesc/util/ParseException.hpp>
> #include <xercesc/dom/DOMDocument.hpp>
> #include <xercesc/framework/MemBufInputSource.hpp>
> 
> int main()
> {
>    try
>    {
>       XMLPlatformUtils::Initialize();
>    }
>    catch (const XMLException &error)
>    {
>       char *msg =
> XMLString::transcode(error.getMessage());
>       cout << "Error during initialization: " << msg
> << endl;
>       return -1;
>    }
> 
>    XercesDOMParser parser;
>    parser.setDoSchema(false);
> 
>
parser.setValidationScheme(XercesDOMParser::Val_Never);
> 
>    // Parse XML file.
>    char *myXMLStr = "<hello>abc</world>";
> 
>    try
>    {
>       MemBufInputSource mbis( (const XMLByte
> *)myXMLStr, strlen(myXMLStr), "dummy", false);
>       parser.parse(mbis);
>    }
>    catch(const XMLException &error)
>    {
>       char *msg =
> XMLString::transcode(error.getMessage());
>       cout << "Error during parsing: " << msg <<
> endl;
>       return -1;
>    }
>    catch (const DOMException &error)
>    {
>       char *msg = XMLString::transcode(error.msg);
>       cout << "Error during parsing: " << msg <<
> endl;
>       return -1;
>    }
>    catch(...)
>    {
>       cout << "Unexpected exception during parsing."
> << endl;
>       return -1;
>    }
> 
>    return 0;
> }
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Finance Tax Center - File online. File on
> time.
> http://taxes.yahoo.com/filing.html
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> xerces-c-dev-help@xml.apache.org
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> xerces-c-dev-help@xml.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: No Parsing Errors?!

Posted by Ashay Shende <as...@cisco.com>.
Hi, If you are using XercesDOMParser, I think you will have to inherit from
ErrorHandler class.
You can then implement the fatalError() method and display the line number
etc where the error occured.

Hope this helps.

-----Original Message-----
From: Monica Lau [mailto:mllau2004@yahoo.com]
Sent: Tuesday, March 30, 2004 6:49 AM
To: xerces-c-dev@xml.apache.org
Subject: No Parsing Errors?!


Hi all,

I am very new to XML as well as to the Xerces XML
parser.  I have a very simple program below to parse
the XML string: "<hello>abc</world>"  When I run this
program, the program runs smoothly, and I don't get
any error messages at all.  I'm not sure what I'm
doing wrong...  Please help -- thanks for your time!

Regards,
Monica


#include <iostream.h>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/ParseException.hpp>
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/framework/MemBufInputSource.hpp>

int main()
{
   try
   {
      XMLPlatformUtils::Initialize();
   }
   catch (const XMLException &error)
   {
      char *msg =
XMLString::transcode(error.getMessage());
      cout << "Error during initialization: " << msg
<< endl;
      return -1;
   }

   XercesDOMParser parser;
   parser.setDoSchema(false);

parser.setValidationScheme(XercesDOMParser::Val_Never);

   // Parse XML file.
   char *myXMLStr = "<hello>abc</world>";

   try
   {
      MemBufInputSource mbis( (const XMLByte
*)myXMLStr, strlen(myXMLStr), "dummy", false);
      parser.parse(mbis);
   }
   catch(const XMLException &error)
   {
      char *msg =
XMLString::transcode(error.getMessage());
      cout << "Error during parsing: " << msg << endl;
      return -1;
   }
   catch (const DOMException &error)
   {
      char *msg = XMLString::transcode(error.msg);
      cout << "Error during parsing: " << msg << endl;
      return -1;
   }
   catch(...)
   {
      cout << "Unexpected exception during parsing."
<< endl;
      return -1;
   }

   return 0;
}


__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


SV:RE: No Parsing Errors?!

Posted by Gröndal Daniel <da...@rfv.sfa.se>.
Monica Lau  (2004-03-30  07:28):
>I expected to get an error about the non-matching start (<hello>) and end
(<world>) XML tags.  I did a little bit more research on this, and I believe
you actually have to install an error handler to print out the error messages.
>

Sounds right.

>I'm not familiar with the Xerces API.  Does anyone have any sample code for a
simple error handler to print out parsing errors?  I've looked at the some of
the samples on the apache website, but they seem very confusing...

Have a look at DOMErrorHandler. Just inherit from this class. This is done in
the sample DOMPrint (look at DOMPrintErrorHandler.cpp and DOMPrintErrorHandler.
hpp).

//daniel

__________________________________________________________
RFV Data/Produktenheten     E-post: daniel.grondal@rfv.sfa.se
Daniel Gröndal              Tfn: 060-187126
S:a Järnvägsgatan 41        Mobil: 070-3016517
851 93 Sundsvall            Fax: 060-147870
__________________________________________________________



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: No Parsing Errors?!

Posted by Monica Lau <ml...@yahoo.com>.
I expected to get an error about the non-matching start (<hello>) and end (<world>) XML tags.  I did a little bit more research on this, and I believe you actually have to install an error handler to print out the error messages.
 
I'm not familiar with the Xerces API.  Does anyone have any sample code for a simple error handler to print out parsing errors?  I've looked at the some of the samples on the apache website, but they seem very confusing...  
 
Thanks for your help and time!
 
Monica


Jimmy Yu <jy...@verizon.net> wrote:
No error?! That is great. Exactly what
kind of error did you expect to get?

No, I did not try to compile and run it. Looking
at it, I did not spot anything obvious that was wrong.

-- Jimmy



> ATTACHMENT part 2 message/rfc822 
From: "Monica Lau" 
To: 
Subject: No Parsing Errors?!
Date: Mon, 29 Mar 2004 17:19:16 -0800

Hi all,

I am very new to XML as well as to the Xerces XML
parser. I have a very simple program below to parse
the XML string: "abc" When I run this
program, the program runs smoothly, and I don't get
any error messages at all. I'm not sure what I'm
doing wrong... Please help -- thanks for your time!

Regards,
Monica


#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

int main()
{
try
{
XMLPlatformUtils::Initialize();
}
catch (const XMLException &error)
{
char *msg =
XMLString::transcode(error.getMessage());
cout << "Error during initialization: " << msg
<< endl;
return -1;
}

XercesDOMParser parser;
parser.setDoSchema(false);

parser.setValidationScheme(XercesDOMParser::Val_Never);

// Parse XML file.
char *myXMLStr = "abc";

try
{
MemBufInputSource mbis( (const XMLByte
*)myXMLStr, strlen(myXMLStr), "dummy", false);
parser.parse(mbis);
}
catch(const XMLException &error)
{
char *msg =
XMLString::transcode(error.getMessage());
cout << "Error during parsing: " << msg << endl;
return -1;
}
catch (const DOMException &error)
{
char *msg = XMLString::transcode(error.msg);
cout << "Error during parsing: " << msg << endl;
return -1;
}
catch(...)
{
cout << "Unexpected exception during parsing."
<< endl;
return -1;
}

return 0;
}


__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org

---------------------------------
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.

RE: No Parsing Errors?!

Posted by Jimmy Yu <jy...@verizon.net>.
No error?! That is great. Exactly what
kind of error did you expect to get?

No, I did not try to compile and run it. Looking
at it, I did not spot anything obvious that was wrong.

-- Jimmy


RE: Compiling Xerces into the .exe and memory managers.

Posted by Trevor Thomson <tr...@laseranalysis.com>.
Thanks, 

I think I have finally managed to get it to work.

Trevor Thomson
Laser Analysis Technologies
www.laseranalysis.com 

-----Original Message-----
From: Vitaly Prapirny [mailto:marl@mebius.net] 
Sent: Thursday, 1 April 2004 5:31 PM
To: xerces-c-dev@xml.apache.org
Subject: Re: Compiling Xerces into the .exe and memory managers.


Hi,

Trevor Thomson wrote:
> I have started to do this but, due to being unfamiliar with the 
> internal workings of the code, have had problems.  The latest being :  
> Error
> directive: A transcoding service must be chosen.
You should use something like XML_USE_WIN32_TRANSCODER in you project 
defines.

Good luck !


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Compiling Xerces into the .exe and memory managers.

Posted by Vitaly Prapirny <ma...@mebius.net>.
Hi,

Trevor Thomson wrote:
> I have started to do this but, due to being unfamiliar with the internal
> workings of the code, have had problems.  The latest being :  Error
> directive: A transcoding service must be chosen.
You should use something like XML_USE_WIN32_TRANSCODER in you project 
defines.

Good luck !


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Compiling Xerces into the .exe and memory managers.

Posted by Trevor Thomson <tr...@laseranalysis.com>.
Hi all,

I have been using Xerces C 2.2.0 (WinXP, BCB5) for about 6 months now and
found it to be quite a good library.  Up until now I have been using the dll
(compiled using BCB5) and a .lib file to statically link the library.  I
have recently read that I should be using the same memory manager for both
the .exe and the .dll.  To do this I would need to use the borland run time
library and distribute the associated dlls with the application.  We would
prefer not to have to worry about extra dlls and so another possible
solution is to compile the Xerces C source into our .exe.  Has anyone done
this before?  Is it possible?

I have started to do this but, due to being unfamiliar with the internal
workings of the code, have had problems.  The latest being :  Error
directive: A transcoding service must be chosen.

I think I understand what it is saying but an unsure how to go about
including the transcoding service.


Can anyone help with my specific problem or am I, perhaps, going about this
the wrong way?


Thanks,

Trevor Thomson

Laser Analysis Technologies
www.laseranalysis.com 


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org