Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Example 23. 2 Constraint Between Components Consider an XML instance document that has two parts: 1.The "what" part describes - using a standard taxonomy.

Similar presentations


Presentation on theme: "1 Example 23. 2 Constraint Between Components Consider an XML instance document that has two parts: 1.The "what" part describes - using a standard taxonomy."— Presentation transcript:

1 1 Example 23

2 2 Constraint Between Components Consider an XML instance document that has two parts: 1.The "what" part describes - using a standard taxonomy - what's in the other part. 2. The "payload" part contains a data component. EXAMPLE #1 The "what" part uses the DMOZ taxonomy to provide the hierarchy for a philosophy book. The "payload" part contains data on a philosophy book. http://www.dmoz.org/Society/Book/Philosophy/ The First and Last Freedom J. Krishnamurti 1954 0-06-064831-7 Harper & Row

3 3 Constraint Between Components EXAMPLE #2 The "what" part uses the DMOZ taxonomy to provide the hierarchy for the Chinese language. The "payload" part contains data on the Chinese language. http://www.dmoz.org/World/Language/Chinese/ Ta

4 4 Constraint Between Components PROBLEM How do you create an NVDL script which will validate that: If the value of the taxonomy attribute is http://www.dmoz.org/Society/Book/Philosophy/ then validate the data component in against: the Book schema If the value of the taxonomy attribute is http://www.dmoz.org/World/Language/Chinese/ then validate the data component in against: the Chinese schema Further... the data components in may be expressed in any schema language (XML Schema, Relax NG, DTD, Schematron). How would you create an NVDL script to do this?

5 5 An NVDL Processor Divides the Instance into Sections N V D L processor http://www.dmoz.org/World/Language/Chinese/ Ta http://www.dmoz.org/World/Language/Chinese/ Ta

6 6 … and then Validates each Section N V D L processor http://www.dmoz.org/World/Language/Chinese/ Ta http://www.dmoz.org/World/Language/Chinese/ Ta Document.xsd Validate Chinese.xsd

7 7 N V D L processor http://www.dmoz.org/World/Language/Chinese/ Ta http://www.dmoz.org/World/Language/Chinese/ Ta How do we express the constraint between the taxonomy value and the payload value?

8 8 Acknowledgement Thanks to George Cristian Bina for explaining to me how to solve this problem (see the following slides for the solution). Thanks George!

9 9 Solution Validate each section independently –Validate the Document section against Document.xsd –Validate the payload section against it's schema Validate a Book section against Book.xsd Validate a Chinese section against Chinese.xsd Attach the payload section to its parent (Document) section and then use Schematron to validate the relationship between the taxonomy and the payload

10 10 NVDL Script <rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" startMode="example"> See following slides for an explanation

11 11 <rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" startMode="example"> Validate the Document section against Document.xsd and then for the child (payload) section switch to the content mode.

12 12 <rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" startMode="example"> Validate a www.book.org payload against book.xsd and a www.chinese.org payload against chinese.xsd

13 13 <rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" startMode="example"> Attach any child sections of www.example.org to its parent, and then use a Schematron schema to validate constraints between the sections.

14 14 Schematron expresses the constraint between the taxonomy value and the payload When taxonomy is http://www.dmoz.org/World/Language/Chinese/ the Payload should contain content from the http://www.chinese.org namespace When taxonomy is http://www.dmoz.org/Society/Book/Philosophy/ the Payload should contain content from the http://www.book.org namespace

15 15 Implementation See the folder example23 for the NVDL script, the schemas, and actual XML instances.

16 16 Validating Constraints Across Components This example has shown how to express constraints across components Furthermore, the components can be expressed in different schema languages. Relax NG DTD Schematron XML Schema Wow!


Download ppt "1 Example 23. 2 Constraint Between Components Consider an XML instance document that has two parts: 1.The "what" part describes - using a standard taxonomy."

Similar presentations


Ads by Google