[xsd-users] Microsoft C++ exception: xercesc_2_6::XMLValid::Codes

Boris Kolpackov boris at codesynthesis.com
Fri Sep 30 07:13:50 EDT 2005


Nelson,

I CC'ed xsd-users so that other can benefit from this info.

nelson.faria <nelson.faria at netcabo.pt> writes:

> This is the XML i'm generating:
>
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <OSGAannotation active="true" checked="false" x="246.991" y="-117.927" z="223.211"/>
>
> and this is the xsd:
>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> 	<xsd:element name="OSGAannotation" type="annotationinfo" />
> 	<xsd:complexType name="annotationinfo">
> 		<xsd:attribute name="x" type="xsd:double" />
> 		<xsd:attribute name="y" type="xsd:double" />
> 		<xsd:attribute name="z" type="xsd:double" />
> 		<xsd:attribute name="active" type="xsd:boolean" />
> 		<xsd:attribute name="checked" type="xsd:boolean" />
> 	</xsd:complexType>
> 	<xsd:complexType name="annotationObject">
> 		<xsd:complexContent>
> 			<xsd:extension base="annotationinfo">
> 				<xsd:sequence>
> 					<xsd:element name="objx" type="xsd:double" />
> 					<xsd:element name="objy" type="xsd:double" />
> 					<xsd:element name="objz" type="xsd:double" />
> 				</xsd:sequence>
> 			</xsd:extension>
> 		</xsd:complexContent>
> 	</xsd:complexType>
> </xsd:schema>
>


> Any thoughts?

I created a small example using your material (test.xsd and test.xml) above:

#include <iostream>

#include "test.hxx"

int
main (int argc, char* argv[])
{
  std::cerr << *OSGAannotation (argv[1]) << std::endl;
}


Then when I ran it I got:

$ ./test test.xml
test.xml:2:85 error: Unknown element 'OSGAannotation'
Aborted

(Aborted is here because I didn't handle exceptions and xsd throws
invalid_instance exception if there were any errors.)

So I looked at your xml an noticed that you don't provide location of the
schema for validation. And xsd, by default, uses strict validation of
instance documents. So I changed your xml to read:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<OSGAannotation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:noNamespaceSchemaLocation="test.xsd"
active="true" checked="false" x="246.991" y="-117.927" z="223.211"/>


$ ./test test.xml

x: 246.991
y: -117.927
z: 223.211
active: 1
checked: 0


> I was really hopping to get this up and running in no time...
> Murphy's back at it ;)

Yeah I noticed the more we hope the less likely it will happen...
unless we try really hard ;-)

hth,
-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20050930/1c3540fb/attachment.pgp


More information about the xsd-users mailing list