How do I use assertions in with Xerces C++ 3.x (CodeSynthesis XSD)?

591 views Asked by At

I have just read through this tutorial on XSD 1.1 assertions:

http://www.ibm.com/developerworks/library/x-xml11pt2/

I copied one of their examples and created this xsd file:

<?xml version="1.1"?>                                                               
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">                             
<xs:element name="dimension">                                                    
  <xs:complexType>                                                               
    <xs:attribute name="height" type="xs:int"/>                                  
    <xs:attribute name="width" type="xs:int"/>                                   
    <xs:assert test="@height = @width"/>                                         
  </xs:complexType>                                                              
</xs:element>                                                                    

</xs:schema>                                                                     

I am trying to parse this to code-gen an hxx file using CodeSynthesis XSD XML Schema to C++ compiler 4.0.0 using the following command:

/path/to/binary cxx-tree /path/to/file.xsd

but I get the following error:

/path/to/file.xsd:7:41: error: invalid element 'assert' in complex type definition

I get the same error when I change the xml version to 1.0. As I understand it the xml version shouldn't matter in this case, but I might be wrong.

What would cause this error message, and how can I fix it?

1

There are 1 answers

2
kjhughes On BEST ANSWER

Your XSD is using assertions properly. (You probably want version="1.0" in your XML declaration as this is the XML version, not the XSD version, but that's not the source of the error.)

Your XSD processor does not support XSD 1.1 if it is rejecting your XSD.

Update: Indeed, according to CodeSynthesis's website, CodeSynthesis XSD 4.0.0 is based upon Xerces-C++, which does not support XSD 1.1. CodeSynthesis really should make this explicit on their product page.