Kbase P121540: How to use XML Schema validation?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  7/3/2009 |
|
Status: Unverified
GOAL:
How to use XML Schema validation?
GOAL:
What are the methods and attributes used for XML Schema validation?
GOAL:
How do you validate an XML File against an XSD file?
FACT(s) (Environment):
OpenEdge 10.1x
OpenEdge 10.2x
All Supported Operating Systems
FIX:
With 10.1A Progress introduced support for validation against XML Schema in DOM and SAX. This validation can be done even if the document does not include schema location information. The schema location can be specified using xsi:schemaLocation attribute if namespaces are used, or xsi:noNamespaceSchemaLocation if no namespaces are used. Or, the validation can be done by simply giving the parser the location of the schema.
To enable validation against an unspecified schema use the ADD-SCHEMA-LOCATION method or the SCHEMA-LOCATION attribute. If no namespaces are declared use the attribute NONAMESPACE-SCHEMA-LOCATION to set the schema location. The following examples illustrate how the method and attributes might be used with a SAX-Reader object:
hSaxReader:ADD-SCHEMA-LOCATION('http://www.example.com', 'com.xsd').
hSaxReader:SCHEMA-LOCATION = 'http://www.example.com com.xsd'.
hSaxReader:NONAMESPACE-SCHEMA-LOCATION = 'com.xsd'.
Once a value is set for SCHEMA-LOCATION or NONAMESPACE-SCHEMA-LOCATION validation is enabled. In order to disable validation those values have to be set to an empty string (""). However, note that if a XML document has references to xsi:schemaLocation or xsi:noNamespaceSchemaLocation, setting SCHEMA-LOCATION and NONAMESPACE-SCHEMA-LOCATION to an empty string is not going to disable validation.