1 how to specify validation information roger l. costello 27 december, 2008

27
1 How to Specify Validation Information Roger L. Costello 27 December, 2008

Upload: nathaniel-whalen

Post on 27-Mar-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

1

How to Specify Validation Information

Roger L. Costello27 December, 2008

Page 2: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

2

Validation Information

<?xml version="1.0"?><Library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://www.book.org Book.xsd http://www.employee.org Employee.xsd"> <Books> … </Books> <Employees> … </Employees></Library>

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.

Page 3: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

3

Embedded Validation Information

<?xml version="1.0"?><Library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://www.book.org Book.xsd http://www.employee.org Employee.xsd"> <Books> … </Books> <Employees> … </Employees></Library>

The validation information is embedded within the XML instance document

Page 4: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

4

It's not always a good idea to embed validation information in

XML instance documents

Reason #1

Page 5: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

5

Document Lifecycle

• Some XML instance documents are validated against different schemas at different stages of the document’s lifecycle, particularly in workflow-based applications.

Rob Sally Pete Jill Anthony

Schema1 Schema2 Schema3 Schema4

XML

Page 6: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

6

Rob Sally Pete Jill Anthony

Schema1 Schema2 Schema3 Schema4

The validation information inside the XML instance document will have to be changed at every stage in the workflow.

XML

Page 7: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

7

It's not always a good idea to embed validation information in

XML instance documents

Reason #2

Page 8: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

8

Diverse Schema Languages

<?xml version="1.0"?><Library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://www.book.org Book.xsd http://www.employee.org Employee.xsd"> <Books> … </Books> <Employees> … </Employees></Library>

This validation information is limited to only XSD schemas

• The XML instance document may be composed of XML vocabularies from different schema languages.

Page 9: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

9

Popular Tag SetsDTD

XHTML

Relax NG

SVG

XML Dig-Sig

XML Schema

GML

Docbook

Atom

IMS Question & Test

DITA

MathML

OAGI

UBL

AECMA 1000D

AECMA 1000D

See here for a couple hundred more: http://xml.coverpages.org/xmlApplications.html

NLM

NLM

NLM

TEI

TEI

Page 10: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

10

If 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?

Page 11: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

11

First, move validation information out of the XML instance and into

a separate document

Page 12: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

12

<?xml version="1.0"?><Library> <Books> … </Books> <Employees> … </Employees></Library>

Validation Information

XML Instance

Page 13: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

13

<?xml version="1.0"?><Library> <Books> … </Books> <Employees> … </Employees></Library>

Validation Information

No validation information in the XML instance document

Page 14: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

14

<?xml version="1.0"?><Library> <Books> … </Books> <Employees> … </Employees></Library>

Validation Information

Express the validation information in a machine-processable fashion

Page 15: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

15

<?xml version="1.0"?><Library> <Books> … </Books> <Employees> … </Employees></Library>

Validation Information

Express the validation information in XML!

Page 16: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

16

<?xml version="1.0"?><Library> <Books> … </Books> <Employees> … </Employees></Library>

Validation Information

Need a standardized XML vocabulary

Page 17: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

17

Is there a standardized XML vocabulary for expressing validation information, which is also independent of schema language?

Page 18: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

18

Yes, there is. It's called NVDL.

Page 19: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

19

NVDL stands for Namespace-based Validation Dispatching Language.

Page 20: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

20

<?xml version="1.0"?><Library> <Books> … </Books> <Employees> … </Employees></Library>

XML Schema Validator

Relax NG Validator

Schematron Validator

DTD Validator

NVDL Processor

Valid!

NVDL

XML Instance

Page 21: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

21

Anatomy of an NVDL Script

<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"> <namespace ns="http://www.book.org"> <validate schema="Book.xsd" /> </namespace> <namespace ns="http://www.employee.org"> <validate schema="Employee.xsd" /> </namespace></rules>

See following slides for explanation →

Library.nvdl

Page 22: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

22

<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"> <namespace ns="http://www.book.org"> <validate schema="Book.xsd" /> </namespace> <namespace ns="http://www.employee.org"> <validate schema="Employee.xsd" /> </namespace></rules>

Library.nvdl

Validate the items in the

http://www.book.org namespace against

Book.xsd

Page 23: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

23

<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"> <namespace ns="http://www.book.org"> <validate schema="Book.xsd" /> </namespace> <namespace ns="http://www.employee.org"> <validate schema="Employee.xsd" /> </namespace></rules>

Library.nvdl

Validate the items in the http://www.employee.org

namespace against Employee.xsd

Page 24: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

24

<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"> <namespace ns="http://www.book.org"> <validate schema="Book.xsd" /> </namespace> <namespace ns="http://www.employee.org"> <validate schema="Employee.xsd" /> </namespace></rules>

Library.nvdl

Standardized XML vocabulary

Page 25: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

25

<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"> <namespace ns="http://www.book.org"> <validate schema="Book.rng" /> </namespace> <namespace ns="http://www.employee.org"> <validate schema="Employee.xsd" /> </namespace></rules>

Library.nvdl

Validate the items in the book.orgnamespaceagainst a Relax NG schema, and the items in the employee.org namespace against an XML Schema

Wow!

Page 26: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

26

XML instance

Validation Information

Clean separation between dataand validation information

Page 27: 1 How to Specify Validation Information Roger L. Costello 27 December, 2008

27

Summary

• 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.