# Guidelines for using W3C XML Schema Datatypes with RELAX NG

## Committee Specification 7 September 2001

This version:
  Committee Specification: 7 September 2001

Editors:
  James Clark `<jjc@jclark.com>`, KAWAGUCHI Kohsuke `<kohsuke.kawaguchi@sun.com>`

Copyright © The Organization for the Advancement of Structured Information Standards [OASIS] 2001. All Rights Reserved.

This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to OASIS, except as needed for the purpose of developing OASIS specifications, in which case the procedures for copyrights defined in the OASIS Intellectual Property Rights document must be followed, or as required to translate it into languages other than English.

The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns.

This document and the information contained herein is provided on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

## Abstract

This document specifies guidelines for using the datatypes defined by [W3C XML Schema Datatypes] with [RELAX NG].

## Status of this Document

This committee specification was approved for publication by the OASIS RELAX NG technical committee. Comments on this document may be sent to relax-ng-comment@lists.oasis-open.org.

## 1. Introduction

This document specifies guidelines for using the datatypes defined by [W3C XML Schema Datatypes] as a datatype library for [RELAX NG]. The URI

    http://www.w3.org/2001/XMLSchema-datatypes

should be used to identify the datatype library. The library identified by this URI contains all the builtin datatypes of [W3C XML Schema Datatypes], both primitive and derived.

## 2. Parameters

Any facet can be specified as a parameter with the following exceptions

- `whiteSpace` (the builtin derived datatype that specifies the desired value for the `whiteSpace` facet should be used instead)
- `enumeration` (the `value` element should be used instead)

If the `pattern` parameter is specified more than once for a single `data` element, then a string matches the `data` element only if it matches all of the patterns. It is an error to specify a parameter other than `pattern` more than once for a single `data` element.

The value of any parameter other than `pattern` should be normalized by applying the normalizeWhiteSpace function defined in [RELAX NG].

## 3. `NOTATION` datatype

The relationship between the `NOTATION` datatype of [W3C XML Schema Datatypes] and the `NOTATION` datatype of [XML 1.0] is different from the relationship between the `ENTITY` datatype of [W3C XML Schema Datatypes] and the `ENTITY` datatype of [XML 1.0]. Whereas values of the `ENTITY` datatype of [W3C XML Schema Datatypes] refer to entities declared in the DTD of document being validated, values of the `NOTATION` datatype of [W3C XML Schema Datatypes] refer to notations declared in the XML Schema. This makes it problematic to use the `NOTATION` datatype outside the context of XML Schema Part 1. However, since [W3C XML Schema Datatypes] does not allow a schema to use the `NOTATION` datatype directly, but requires that a value be specified for the `enumeration` facet, and since the values of the `NOTATION` datatype are QNames, the `NOTATION` datatype is, considering just validation, effectively equivalent to the `QName` datatype. It is therefore recommended that RELAX NG validators implement the same validation semantics for the `NOTATION` datatype as for the `QName` datatype.

## 4. `ID`, `IDREF` and `IDREFS` datatypes

The semantics defined by [W3C XML Schema Datatypes] for the `ID`, `IDREF` and `IDREFS` datatypes are purely lexical and do not include the cross-reference semantics of the corresponding [XML 1.0] datatypes. The cross-reference semantics of these datatypes in XML Schema comes from XML Schema Part 1. Furthermore, the [XML 1.0] cross-reference semantics of these datatypes do not fit into the RELAX NG model of what a datatype is. Therefore, RELAX NG validation will only validate the lexical aspects of these datatypes as defined in [W3C XML Schema Datatypes].

However, [DTD Compatibility] defines the concept of an ID-type, which is an additional semantic for datatypes that allows datatypes to have [XML 1.0] cross-reference semantics. An implementation of [DTD Compatibility] that supports these guidelines should associate the `ID`, `IDREF` and `IDREFS` datatypes of [W3C XML Schema Datatypes] with the ID-types ID, IDREF, and IDREFS respectively.

## References

Tim Bray, Jean Paoli, and C. M. Sperberg-McQueen, Eve Maler, editors. Extensible Markup Language (XML) 1.0 Second Edition. W3C (World Wide Web Consortium), 2000.

James Clark, Makoto MURATA, editors. RELAX NG Specification. OASIS, 2001.

James Clark, Makoto MURATA, editors. RELAX NG DTD Compatibility. OASIS, 2001.

Paul V. Biron, Ashok Malhotra, editors. XML Schema Part 2: Datatypes. W3C (World Wide Web Consortium), 2001.