Syntax

Revision History
Revision 0.12007-03-07Dave Pawson

Initial Issue

This chapter address various (pretty minor) syntax issues. If you want the whole story, see the full Relax NG schema, or nvdl.html which is a prettier version of the same information.

I stated earlier that I will only use Relax NG syntax for the schemas and sub-schemas. Taking an example of others is not a problem. Example 6.1

Example 6.1. Alternate schema usage

<?xml version="1.0" encoding="utf-8"?>
<!-- syntax.ex1.nvdl -->
<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" 
       startMode="doc">

  <mode name="doc">
    <namespace ns="http://document">                                 
      <validate                                    1
      message="A variant on the schema specification"           
      schemaType="application/x-rnc">                 2
	<schema>routing.1.rnc</schema>
      </validate>
    </namespace>
  </mode>

  <mode name="rest">
    <namespace ns="http://head" >
      <validate schema="routing.1.xsd" />  
    </namespace>

    <namespace ns="http://body">
      <validate  schemaType="application/xml-dtd" 
      schema="routing.1.dtd" />          3
    </namespace>
  </mode>
</rules>        
   
  
1

Rather than using the schema attribute this example uses the schema element. The message attribute enables helpful comments in the script.

2

Validating with the abbreviated syntax, the schemaType must be specified.

3

We can even use DTD's.


Due care though. The standard says, “If v contains a schema element as a child, its content is used as the schema. When the content is a string and v has the schemaType attribute, its value shall be a MIME mediatype (see IETF RFC2046) and be used for determining the schema language. When the content is a foreign element, its namespace is used for determining the schema language.” Put simply, if it's a modern XML based schema language, then you should be OK. Otherwise specify the mimetype as per RFC2046 (ietf rfc2046).

Legal Notice