Page 1 of 1

NVDL and custom XHTML 5

Posted: Fri Apr 04, 2014 6:40 pm
by ari
I'm an XML beginner so bare with me.

From what I understand by searching in the forums XHTML Validation is done using NVDL schema

Oxygen uses the following NVDL schema to provide validation and content completion for XHTML 5 documents:

OXYGEN_INSTALL_DIR/frameworks/xhtml/xhtml5 (epub3)/epub-xhtml-30.nvdl

Among other things I'm looking for a way to customize the available attributes and their values for the "section" element in XHTML 5

e.g role attribute can only have values: x|y|z

if I'm not mistaken there is no .xsd for XHTML 5 available so this could possibly be achieved by learning Relax NG Compact.

What would be a good way of doing this - should I be editing the already existing rnc files?

Re: NVDL and custom XHTML 5

Posted: Mon Apr 07, 2014 11:33 am
by Radu
Hi Ari,

Indeed the main schema for editing XHTML 5 documents is located here:

OXYGEN_INSTALL_DIR\frameworks\xhtml\xhtml5 (epub3)\epub-xhtml-30.nvdl[b]

It's a schema we copied from the EpubCheck open source EPUB checker project.

NVDL schemas basically can use multiple schemas in multiple contexts to validate certain parts of an XML document.
If you look inside the NVDL schema, besides its reference to the [b]epub-xhtml-30.rnc
Relax NG compact schema, it also has a reference to a Schematron schema.

You can also add an additional reference to your own Schematron schema like:

Code: Select all

<validate schema="custom.sch" useMode="attach"/>

and your custom.sch can have the content:

Code: Select all

<schema xmlns="" queryBinding="xslt2">
    <ns uri="" prefix="h"/>
        <rule context="h:section">
            <assert test="@role='X' or @role='Y' or @role='Z'">The @role attribute should have values X Y and Z</assert>

Whenever the user will insert a different value for @role Oxygen will show a validation error.

If you also want those allowed values to be proposed in the content completion window as valid entries when the user inserts the @role attribute you will need to make the change to the Relax NG compact schemas. The "role" attribute is defined in this RNC file:

OXYGEN_INSTALL_DIR/frameworks/xhtml/xhtml5 (epub3)/mod/html5/html5-aria-30.rnc

Code: Select all

aria.role.attr = attribute role { datatype.NMTOKENS }

and you can change its definition to:

Code: Select all

aria.role.attr = attribute role { 'X' | 'Y' | 'Z' }

The downside is that all @role attributes on all elements will be restricted (not only the ones for <section>). If you want only to influence role attribute values for <section>, you need to make more drastic changes to the schemas.


Re: NVDL and custom XHTML 5

Posted: Mon Apr 07, 2014 6:33 pm
by ari
@Radu, thank you this is exactly what I was looking for.