This section describes the built-in datatype 'NCName' designed to support XML element and attribute names with no namespace prefix. 'NCName', stands for 'Non-Colonized Name', datatype is derived from 'Name' by removing ':' from the 'Name' value pattern.
If you look at string pattern used to define "Name" values,
you will see colon ":" is allowed in "Name" values.
This is needed to support XML element names that uses namespances like "xs:complexType".
In order to support "Name" values without ":", XSD provides another datatype called "NCName"
stands for "Non-Colonized Name".
"NCName" is a datatype derived from the "Name" datatype
by removing ":" from the "Name" value pattern.
Here is a sample XSD document that defines a sub element <NCName> to use "NCName" values:
Here is a sample XML document that contains <NCName> elements to test that definition:
<?xml version="1.1"?>
<!-- NCName_datatype_test.xml
- Copyright (c) 2013, HerongYang.com, All Rights Reserved.
-->
<NCName_Datatype_Test>
<!-- 5 valid "NCName" elements -->
<NCName>name_datatype_test</NCName>
<NCName>complexType</NCName>
<NCName> w3.org </NCName>
<NCName> head </NCName>
<NCName> 头</NCName>
<!-- 5 invalid "NCName" elements -->
<NCName> xs:token</NCName>
<NCName>complex Type</NCName>
<NCName> (html)</NCName>
<NCName> xs+token</NCName>
<NCName> 1st_head</NCName>
</NCName_Datatype_Test>
Again, the JDK 1.7 tool XsdSchemaValidator.java works nicely on this test.
It reports 5 groups of errors for the last 5 invalid elements.
But error messages do not provide the "NCName" string pattern