Title: How to Specify Validation Information
1How to Specify Validation Information
- Roger L. Costello
- 27 December, 2008
2Validation Information
Validate the items in the http//www.book.org
namespace against Book.xsd, and the items in the
http//www.employee.org namespace against
Employee.xsd.
lt?xml version"1.0"?gt ltLibrary xmlnsxsi"http//w
ww.w3.org/2001/XMLSchema-instance"
xsischemaLocation
"http//www.book.org
Book.xsd http//www.employee.o
rg Employee.xsd"gt
ltBooksgt lt/Booksgt ltEmployeesgt
lt/Employeesgt lt/Librarygt
3Embedded Validation Information
lt?xml version"1.0"?gt ltLibrary xmlnsxsi"http//w
ww.w3.org/2001/XMLSchema-instance"
xsischemaLocation
"http//www.book.org
Book.xsd http//www.employee.o
rg Employee.xsd"gt
ltBooksgt lt/Booksgt ltEmployeesgt
lt/Employeesgt lt/Librarygt
The validation information is embedded within the
XML instance document
4It's not always a good idea to embed validation
information in XML instance documents
Reason 1 ?
5Document Lifecycle
- Some XML instance documents are validated against
different schemas at different stages of the
documents lifecycle, particularly in
workflow-based applications.
Schema3
Schema4
Schema2
Schema1
XML
6The validation information inside the XML
instance document will have to be changed at
every stage in the workflow.
Schema3
Schema4
Schema2
Schema1
XML
7It's not always a good idea to embed validation
information in XML instance documents
Reason 2 ?
8Diverse Schema Languages
- The XML instance document may be composed of XML
vocabularies from different schema languages.
lt?xml version"1.0"?gt ltLibrary xmlnsxsi"http//w
ww.w3.org/2001/XMLSchema-instance"
xsischemaLocation
"http//www.book.org
Book.xsd http//www.employee.o
rg Employee.xsd"gt
ltBooksgt lt/Booksgt ltEmployeesgt
lt/Employeesgt lt/Librarygt
This validation information is limited to only
XSD schemas
9Popular Tag Sets
DTD
Relax NG
MathML
AECMA 1000D
Atom
SVG
TEI
XHTML
Docbook
TEI
OAGI
XML Dig-Sig
NLM
DITA
NLM
XML Schema
UBL
GML
NLM
IMS Question Test
AECMA 1000D
See here for a couple hundred more
http//xml.coverpages.org/xmlApplications.html
10If I don't put the validation information inside
the XML instance document, where do I put that
information? How do I express the information in
a way that is not specific to one schema language?
11First, move validation information out of the XML
instance and into a separate document ?
12XML Instance
lt?xml version"1.0"?gt ltLibrarygt ltBooksgt
lt/Booksgt ltEmployeesgt
lt/Employeesgt lt/Librarygt
Validation Information
13No validation information in the XML instance
document
lt?xml version"1.0"?gt ltLibrarygt ltBooksgt
lt/Booksgt ltEmployeesgt
lt/Employeesgt lt/Librarygt
Validation Information
14lt?xml version"1.0"?gt ltLibrarygt ltBooksgt
lt/Booksgt ltEmployeesgt
lt/Employeesgt lt/Librarygt
Validation Information
Express the validation information in a
machine-processable fashion
15lt?xml version"1.0"?gt ltLibrarygt ltBooksgt
lt/Booksgt ltEmployeesgt
lt/Employeesgt lt/Librarygt
Validation Information
Express the validation information in XML!
16lt?xml version"1.0"?gt ltLibrarygt ltBooksgt
lt/Booksgt ltEmployeesgt
lt/Employeesgt lt/Librarygt
Validation Information
Need a standardized XML vocabulary
17Is there a standardized XML vocabulary for
expressing validation information, which is also
independent of schema language?
18Yes, there is. It's called NVDL.
19NVDL stands for Namespace-based Validation
Dispatching Language.
20XML Instance
lt?xml version"1.0"?gt ltLibrarygt ltBooksgt
lt/Booksgt ltEmployeesgt
lt/Employeesgt lt/Librarygt
NVDL Processor
XML Schema Validator
Relax NG Validator
Valid!
Schematron Validator
DTD Validator
NVDL
21Anatomy of an NVDL Script
ltrules xmlns"http//purl.oclc.org/dsdl/nvdl/ns/st
ructure/1.0"gt ltnamespace ns"http//www.book
.org"gt ltvalidate schema"Book.xsd"
/gt lt/namespacegt ltnamespace
ns"http//www.employee.org"gt
ltvalidate schema"Employee.xsd" /gt
lt/namespacegt lt/rulesgt
Library.nvdl
See following slides for explanation ?
22Validate the items in the http//www.book.org
namespace against Book.xsd
ltrules xmlns"http//purl.oclc.org/dsdl/nvdl/ns/st
ructure/1.0"gt ltnamespace ns"http//www.book
.org"gt ltvalidate schema"Book.xsd"
/gt lt/namespacegt ltnamespace
ns"http//www.employee.org"gt
ltvalidate schema"Employee.xsd" /gt
lt/namespacegt lt/rulesgt
Library.nvdl
23Validate the items in the http//www.employee.org
namespace against Employee.xsd
ltrules xmlns"http//purl.oclc.org/dsdl/nvdl/ns/st
ructure/1.0"gt ltnamespace ns"http//www.book
.org"gt ltvalidate schema"Book.xsd"
/gt lt/namespacegt ltnamespace
ns"http//www.employee.org"gt
ltvalidate schema"Employee.xsd" /gt
lt/namespacegt lt/rulesgt
Library.nvdl
24ltrules xmlns"http//purl.oclc.org/dsdl/nvdl/ns/st
ructure/1.0"gt ltnamespace ns"http//www.book
.org"gt ltvalidate schema"Book.xsd"
/gt lt/namespacegt ltnamespace
ns"http//www.employee.org"gt
ltvalidate schema"Employee.xsd" /gt
lt/namespacegt lt/rulesgt
Standardized XML vocabulary
Library.nvdl
25Wow!
ltrules xmlns"http//purl.oclc.org/dsdl/nvdl/ns/st
ructure/1.0"gt ltnamespace ns"http//www.book
.org"gt ltvalidate schema"Book.rng"
/gt lt/namespacegt ltnamespace
ns"http//www.employee.org"gt
ltvalidate schema"Employee.xsd" /gt
lt/namespacegt lt/rulesgt
Validate the items in the book.org namespace again
st a Relax NG schema, and the items in the
employee.org namespace against an XML Schema
Library.nvdl
26XML instance
Clean separation between data and validation
information
Validation Information
27Summary
- Oftentimes XML developers embed validation
information within their instance documents. - This may not be a good idea for these reasons
- In the lifecycle of an instance document it may
need to be validated against different schemas.
If validation information is embedded in the
instance document then the instance document will
need to be changed at each stage of the
lifecycle. That's costly. - The embedded validation information is limited to
one schema language. You may want to utilize XML
vocabularies that were created using different
schema languages. - Recommendations
- Remove validation information from XML instance
documents. - Put the validation information into a separate
document. - Use a standardized XML vocabulary for expressing
validation information. - NVDL is a standardized XML vocabulary for
expressing validation information. Use NVDL.