Go to the table of contents.1 Using NVDL for Validation of ITS Markup

NVDL is schema language which was specially created for validation of compound documents. Compound document is document which consists of elements from several namespaces. This means that every document using ITS markup is also compound document and NVDL can be used for its validation.

The fundamental idea behind NVDL is that document is split into sections consisting of elements from single namespace before validation. Those sections are then validated against respective schemas. Moreover it is possible to specify how elements from different namespaces can be combined together in XML instances.

NVDL approach has several advantages over direct integration of ITS markup into target schema. These advantages are:

Suppose the following sample XHTML+ITS document:

<html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:its="http://www.w3.org/2005/11/its" lang="en" xml:lang="en">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="keywords" content="ITS example, XHTML translation" />
  <its:rules version="1.0" xmlns:h="http://www.w3.org/1999/xhtml">
   <its:translateRule selector="//h:meta[@name='keywords']/@content"
    translate="yes" />
   <its:termRule selector="//h:span[@class='term']" term="yes" />
  </its:rules>
  <title>ITS Working Group</title>
 </head>
 <body>
  <h1>Test of ITS on <span class="term">XHTML</span></h1>
  <p>Some text to translate.</p>
  <p its:translate="no">Some text not to translate.</p>
 </body>
</html>

For purposes of NVDL validation this document is first split into the following sections.

Section 1:
<html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:its="http://www.w3.org/2005/11/its" lang="en" xml:lang="en">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="keywords" content="ITS example, XHTML translation" />
  (… reference to Section 2)
  <title>ITS Working Group</title>
 </head>
 <body>
  <h1>Test of ITS on <span class="term">XHTML</span></h1>
  <p>Some text to translate.</p>
  <p (… reference to Section 3)>Some text not to translate.</p>
 </body>
</html>

Section 2:
<its:rules version="1.0" xmlns:h="http://www.w3.org/1999/xhtml">
 <its:translateRule selector="//h:meta[@name='keywords']/@content"
  translate="yes" />
 <its:termRule selector="//h:span[@class='term']" term="yes" />
</its:rules>

Section 3 (attribute section):
<… its:translate="no">

In NVDL it is possible to send sections to appropriate schemas for validation. It is even possible to combine sections back to larger fragments before validation.

The basic NVDL schema for XHTML+ITS could be the following.

Example 1: The very basic NVDL schema for XHTML+ITS
<?xml version="1.0" encoding="UTF-8"?>
<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0">
  <namespace ns="http://www.w3.org/1999/xhtml">
    <validate schema="xhtml10/xhtml1-frameset.xsd"/>
  </namespace>
  <namespace ns="http://www.w3.org/2005/11/its">
    <validate schema="its-elements.rng"/>   
  </namespace>
  <namespace ns="http://www.w3.org/2005/11/its" match="attributes">
    <validate schema="its-attributes.rng"/>
  </namespace>
</rules>

With such schema XHTML section (section 1) will be validated against XHTML schema, section 2 with ITS rules will be validated against schema for ITS elements and finally section 3 with ITS local attributes will be validated against schema for ITS attributes.

In practice, we usually need to be more restrictive. For example in case of XHTML we want to restrict that ITS rules element can occur only in head element.

First we must create schema which will validate only rules. This is very easy as ITS schema contains many reusable named patterns.

Example 2: RELAX NG schema for ITS rules element
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">

  <include href="its.rng"/>

  <start>
    <ref name="its-rules"/>
  </start>

</grammar>

Then in NVDL we can specify that validation against this schema is done only for elements inside head.

Example 3: Better NVDL schema for XHTML+ITS
<?xml version="1.0" encoding="UTF-8"?>
<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"
       startMode="xhtml">
  <mode name="xhtml">
    <namespace ns="http://www.w3.org/1999/xhtml">
      <validate schema="xhtml10/xhtml1-transitional.xsd" useMode="its-local-markup">
        <context path="head" useMode="its-rules"/>
      </validate>
    </namespace>
  </mode>
  <mode name="its-rules">
    <namespace ns="http://www.w3.org/2005/11/its">
      <validate schema="its-rules.rng"/>   
    </namespace>
  </mode>
  <mode name="its-local-markup">
    <namespace ns="http://www.w3.org/2005/11/its" match="attributes">
      <validate schema="its-attributes.rng"/>
    </namespace>
    <anyNamespace>
      <attach/>
    </anyNamespace>
  </mode>
</rules>