www.alphaworks.ibm.comwww.ibm.com/developerwww.ibm.com

Home

Readme
Download

Build Instructions







Migration

Releases

Feedback

Y2K Compliance


CVS Repository
Mail Archive

Disclaimer
 

Schema is not fully supported in XML4C yet. But an experimental implementation of a subset of the W3C XML Schema language is now available for review in XML4C 3.5.1. You should not consider this implementation complete or correct. The limitations of this implementation are detailed below. Please read this document before using XML4C 3.5.1.


Introduction
 

The XML4C 3.5.1 contains an implementation of a subset of the W3C XML Schema Language as specified in the 2 May 2001 Recommendation for Structures and Datatypes. The parsers contained in this package are able to read and validate XML documents with the grammar specified in either DTD or XML Schema format.

We intend to update this package until it implements all the functionality of the current XML Schema Recommendation. If you are interested in a particular unimplemented feature, or if you have any feedback on the implementation design, we welcome your input to the Xerces-C mailing list xml4c@us.ibm.com .


Limitations
 

The XML Schema implementation in the XML4C 3.5.1 is a subset of the features defined in the 2 May 2001 XML Schema Recommendation.


Features/Datatypes Supported
 
  • Partial Simple type support
    • Yes: atomic simple type
    • No: union and list
  • Partial Complex type suppport
    • Yes: choice, sequence
    • No: group, all
  • Element and Attribute Declaration
    • No: any/anyAttribute
  • SubsitutionGroup
  • Subset of Built-in Datatypes
    • Primitive Datatypes
      • string
      • boolean
      • decimal
      • hexbinary
      • base64binary
    • Derived Datatypes
      • integer
  • xsi Markup
    • Yes: xsi:nil
    • Yes: xsi:schemaLocation and xsi:noNamespaceSchemaLocation
    • No: xsi:type

Additional Experimental Features (not tested and subject to change, use as is)

  • Complex type derivation support (simpleContent and complexContent).
  • Element and attribute re-use using "ref".
  • Include support
  • Import Support
  • Element declaration <any>
  • Subset of Built-in Datatypes
    • Derived Datatypes
      • normalizedString
      • token
      • language
      • Name
      • NCName
      • NMTOKEN
      • NMTOKENS
      • ID
      • IDREF
      • IDREFS
      • ENTITY
      • ENTITIES
      • nonNegativeInteger

Other features in the Schema recommendation such as "redefine", "identity constraints" and others which are not mentioned above, are not supported yet. Also, particle and model group constraint checking is not yet fully implemented. But development is continuing and we target to implement all the features of the current XML Schema Recommendation before end of this year. Please note that the date is tentative and subject to change.


Other Limitations
 

The schema must be specified by the xsi:schemaLocation or xsi:noNamespaceSchemaLocation attribute on the root element of the document. The xsi prefix must be bound to the Schema document instance namespace, as specified by the Recommendation. See the sample provided in the Usage section.


Usage
 

XML document specifies the XML Schema grammar location in the xsi:schemaLocation attribute attached to the root / top-level element. Here is an example with no target namspace:

<?xml version="1.0" encoding="UTF-8"?>
<personnel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	   xsi:noNamespaceSchemaLocation='personal.xsd'>
...
</personnel>

Please see the sample file, 'samples/data/personal-schema.xml' for further detail. And review the sample file 'samples/data/personal.xsd' for an example of an XML Schema grammar.

Here is an example how to turn on schema processing in DOMParser (default is off). Note that you must also turn on namespace support (default is off) for schema processing.

// Instantiate the DOM parser.
DOMParser parser;
parser.setDoNamespaces(true);
parser.setDoSchema(true);
parser.parse(xmlFile);

Usage in SAXParser is similar, please refer to the sample program 'samples/SAXCount/SAXCount.cpp' for further reference.

Here is an example how to turn on schema processing in SAX2XMLReader (default is on). Note that namespace must be on (default is on) as well.

SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
parser->setFeature(XMLString::transcode("http://xml.org/sax/features/namespaces"), true);
parser->setFeature(XMLString::transcode("http://apache.org/xml/features/validation/schema"), true);
parser->parse(xmlFile);

Footer