Special-Purpose Schema Languages





Special-Purpose Schema Languages

We have until now considered general-purpose schema languages, which can be used for XML documents of any kind. However, some schema languages are dedicated to particular kinds of XML documents. Furthermore, a framework for combining multiple schema languages has been proposed.

1 RDF Schema

RDF Schema is a schema language for XML documents representing Resource Description Framework (RDF) metadata. The basic constructs in the data model of RDF are resources, properties, and statements. To represent RDF metadata with an XML document, such basic constructs are represented by elements or attributes. Applications for handling RDF metadata are concerned about the basic constructs of RDF metadata rather than elements or attributes.

Schemas written in RDF Schema (see Listing 16.6) describe permissible basic constructs and their structural relationships. They do not directly handle elements or attributes. As far as RDF metadata is concerned, RDF Schema provides higher abstraction than general-purpose schema languages, and is thus expected to make schema authoring and metadata access easier.

RDF Schema example borrowed from the W3C Candidate Recommendation for RDF Schema.
<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xml:lang="en"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">

  <rdf:Description ID="registeredTo">
    <rdf:type resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#
    Property"/>
    <rdfs:domain rdf:resource="#MotorVehicle"/>
    <rdfs:range rdf:resource="#Person"/>
  </rdf:Description>

  <rdf:Description ID="rearSeatLegRoom">
    <rdf:type resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#
    Property"/>
    <rdfs:domain rdf:resource="#PassengerVehicle"/>
    <rdfs:domain rdf:resource="#Minivan"/>
    <rdfs:range
        rdf:resource="http://www.w3.org/2000/03/example/
        classes#Number"/>
  </rdf:Description>

</rdf:RDF>

In general, although a special-purpose schema language has a limited use, it provides features tailored to that use and also provides higher abstraction. Therefore, special-purpose schema languages are easier to understand and enable easy access to particular types of documents, as long as the market is big enough to justify tool development for special-purpose schema languages.

Besides RDF Schema, other special-purpose schema languages may emerge. For example, the Topic Map Constraint Language, already in progress at ISO/IEC JTC SC34, is a special-purpose schema language for XML documents representing topic maps. WSDL, explained in Chapter 13, can be seen as another special-purpose schema language.

2 RELAX Namespace

It is highly unlikely that a single general-purpose schema language will over shadow all other schema languages. Although only a single general-purpose one may survive, some special-purpose ones are likely to provide more advantages and thus also survive.

Different schema languages have different target documents. If the targets of schema languages do not overlap, we only have to use the schema language most appropriate for the task at hand.

However, different parts of a single XML document may require different schema languages. An example is an XHTML document containing RDF metadata. RDF Schema is appropriate for the RDF metadata, while general-purpose schema languages such as RELAX NG are appropriate for the body of the XHTML document. To create a schema for such an XHTML document, we need a framework so that RELAX NG and RDF Schema can be combined.

RELAX Namespace has been designed as such a framework. For a single multi namespace XML document, we can use different schema languages for different namespaces and combine them by using RELAX Namespace. In the XHTML+RDF example, we create a schema for the XHTML namespace in RELAX NG or RELAX Core and create another schema for the metadata namespace in RDF Schema. We then combine these schemas by writing a RELAX Namespace framework, as shown in Listing 16.7.

RELAX Namespace example
       <?xml version="1.0" encoding="utf-8"?>
[2]    <framework xmlns="http://www.xml.gr.jp/xmlns/relaxNamespace"
           relaxNamespaceVersion="1.0">

[5]      <namespace name="http://www.example.net/document"
              moduleLocation="doc.rxm"/>

[8]      <namespace name="http://www.example.net/metadata"
              moduleLocation="meta.rdfs"
              language="http://www.w3.org/2000/01/rdf-schema#"/>

[12]     <topLevel>
          <ref name="doc" namespace="http://www.example.net/document"
               xmlns="http://www.xml.gr.jp/xmlns/relaxCore"/>
         </topLevel>

       </framework>

This RELAX Namespace schema combines two schemas for two namespaces. The root element of this schema is a framework element (line 2). It has two namespace elements (lines 5 and 8) and one topLevel element (line 12). The first namespace associates a RELAX Core schema, doc.rxm, with the namespace http://www.example.net/document, and the second namespace associates an RDF Schema, schema meta.rdfs, with the namespace http://www.w3.org/2000/01/rdf-syntax. The topLevel element specifies that the root of an instance document is a doc element of the first namespace.

RELAX Namespace was designed together with RELAX Core in Japan. As of this writing, RELAX Namespace is a Draft Technical Report of ISO/IEC (ISO/IEC DTR 22250-2).


     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows