XML Schema Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 4.11

Built-in Datatype - "string" Errors

This section describes a tutorial example on validation errors against string restriction facets.

In the previous section, we created a schema using "string" datatype with different restriction facets. Now we are going to create an XML document, string_datatype_error.xml, with several validation errors:

<?xml version="1.0"?>
<canadaAddress
 street="7 M."
 city="  Toronto "
 provinceCode="Ontario"
 zip="M3C LT3"
/>

Here is the output of XsdSchemaValidator.java:

>java XsdSchemaValidator string_datatype.xsd 
   string_datatype_error.xml

Error:
   Line number: 7
   Column number: 3
   Message: cvc-minLength-valid: Value '7 M.' with length = '4' is 
   not facet-valid with respect to minLength '5' for type 
   '#AnonType_streetcanadaAddress'.

Error:
   Line number: 7
   Column number: 3
   Message: cvc-attribute.3: The value '7 M.' of attribute 'street'
   on element 'canadaAddress' is not valid with respect to its 
   type, 'null'.

Error:
   Line number: 7
   Column number: 3
   Message: cvc-length-valid: Value 'Ontario' with length = '7' is 
   not facet-valid with respect to length '2' for type 
   '#AnonType_provinceCodecanadaAddress'.

Error:
   Line number: 7
   Column number: 3
   Message: cvc-attribute.3: The value 'Ontario' of attribute 
   'provinceCode' on element 'canadaAddress' is not valid with 
   respect to its type, 'null'.

Error:
   Line number: 7
   Column number: 3
   Message: cvc-pattern-valid: Value 'M3C LT3' is not facet-valid
   with respect to pattern '[A-Z][0-9][A-Z] [0-9][A-Z][0-9]' for 
   type '#AnonType_zipcanadaAddress'.

Error:
   Line number: 7
   Column number: 3
   Message: cvc-attribute.3: The value 'M3C LT3' of attribute 'zip'
   on element 'canadaAddress' is not valid with respect to its 
   type, 'null'.

Failed with errors: 6

Table of Contents

 About This Book

 Introduction to XML Schema

 XML Editor and Schema Processor - XMLPad

 Java API for XML Processing - JAXP

 JAXP - XML Schema (XSD) Validation

 XML Parser API - Xerces2 Java Parser

 XML Schema Language - Basics

XML Schema Built-in Datatypes

 Overview of XML Schema Built-in Datatypes

 List of Built-in Datatypes

 Deriving from Built-in Datatypes - simpleType

 Built-in Datatype - "string"

Built-in Datatype - "string" Errors

 Built-in Datatype - "dateTime"

 Built-in Datatype - "dateTime" Errors

 Built-in Datatype - "decimal"

 Built-in Datatype - "decimal" Errors

 Complex Element Declaration

 XML Schema Location and Namespace in XML Documents

 Overriding Element Types in XML Documents

 Linking Multiple Schema Documents Together

 Glossary

 References

 PDF Printing Version

Dr. Herong Yang, updated in 2009
Built-in Datatype - "string" Errors