[xsd-users] Fwd: Extended exception information

David White dawhite32 at gmail.com
Fri Apr 17 01:50:30 EDT 2009


Dear xsd-users,

I think I have just worked it out:

catch (const ::xml_schema::parsing& e)
{
  stringstream ss("");
  ss << e.what();

  ::xsd::cxx::parser::diagnostics<char>::const_iterator _it =
e.diagnostics().begin();
  for (_it; _it!=e.diagnostics().end(); _it++)
  {
    ss << endl;
    ss << "  - line " << _it->line();
    ss << ", column " <<  _it->column();
    ss << ", severity " <<  _it->severity() << endl;
    ss << "  - " << _it->message();
  }
  cerr << ss.str();
}

This is exactly what I was looking for... unless you can think of a
better way???

Kind regards, David.


---------- Forwarded message ----------
From: David White <dawhite32 at gmail.com>
Date: Fri, Apr 17, 2009 at 2:55 PM
Subject: Fwd: Extended exception information
To: xsd-users at codesynthesis.com


I forgot to add - I am using xsd-parser, not xsd-tree.

David.


---------- Forwarded message ----------
From: David White <dawhite32 at gmail.com>
Date: Fri, Apr 17, 2009 at 2:52 PM
Subject: Extended exception information
To: xsd-users at codesynthesis.com


Dear Boris,

Consider a complex type defined as follows:

<xs:complexType>
 <xs:sequence>
   <xs:element ref="X"/>
   <xs:element ref="Y"/>
   <xs:element ref="Z"/>
   <xs:element ref="Position" minOccurs="0" maxOccurs="unbounded"/>
 </xs:sequence>
</xs:complexType>

If I attempt to parse an XML file which has the X, Y, Z in a different
order, for example:

<Position>
 <Y>63.745</Y>
 <Z>200.809</Z>
 <X>-186.489</X>
</Position>

I get an "instance document parsing failed", which is what I expect to
get. No problems there.  My question is - how do I get extended
exception information as to where the error is?  I am trapping the
exception via:

catch (const ::xml_schema::exception& e)
{
   // print message
   cerr << e.what() << endl;
}

Is there another class that will give me extended information?

Thanks in advance.

Kind regards, David.




More information about the xsd-users mailing list