22. relaxng
Prev | Chapter 7. Configuration elements | Next

## 22. relaxng

    <relaxng
      location = anyURI
      compactSyntax = boolean
      encoding = any encoding supported by Java™
    />

Use the RELAX NG schema specified by this element to constrain the document.

location

  Required. Specifies the URL of the RELAX NG schema.

compactSyntax

  Specifies that the RELAX NG schema is written using the compact syntax. Without this attribute, if `location` has a "`rnc`" extension, the schema is assumed to use the compact syntax, otherwise it is assumed to use the XML syntax.

encoding

  Specifies the character encoding used for a RELAX NG schema written using the compact syntax. Ignored if the XML syntax is used. Without this attribute, the schema is assumed to use the native encoding of the platform.

Note that

- if a document contains a document type declaration (<!DOCTYPE>) which defines elements,

- or if the root element of a document has `xsi:schemaLocation`/`xsi:noNamespaceSchemaLocation` attributes,

- of if a document contains a `<?xml-model href="..."?>`,

the grammar specified this way is used and the RELAX NG schema specified in the configuration file is ignored.

Example:

    <relaxng location="rng/xhtml-strict.rng" />

Compact syntax example:

    <relaxng compactSyntax="true" encoding="ISO-8859-1"
             location="example3.rnc" />

### Validating RELAX NG schemas or ISO Schematrons

If your configuration allows to edit RELAX NG schemas, you'll typically specify:

    <relaxng location="rng/relaxng.rng" />

where `rng/relaxng.rng` is a copy of the RELAX NG schema for RELAX NG.

However, it is also possible to validate the document being edited using XXE's built-in schema validator. This kind of validation is more comprehensive than the one performed by the RELAX NG schema for RELAX NG alone. This is achieved by referencing the "`xxe-schema-for-relaxng`" dummy URI:

    <relaxng location="xxe-schema-for-relaxng" />

The same trick also applies to ISO Schematrons, which are normally validated against the RELAX NG schema for ISO Schematron (`iso-schematron.rnc`). In this case, you'll have to reference the "`xxe-schema-for-schematron`" dummy URI.

Prev | Up | Next
21. preserveSpace | Home | 23. saveOptions