NVDL and custom XHTML 5

Post here issues about NVDL, not specifically linked to the oNVDL implementation.
Posts: 10
Joined: Sun Apr 01, 2012 1:17 pm

NVDL and custom XHTML 5

Post by ari » Fri Apr 04, 2014 6:40 pm

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?

Posts: 7531
Joined: Fri Jul 09, 2004 5:18 pm

Re: NVDL and custom XHTML 5

Post by Radu » Mon Apr 07, 2014 11:33 am

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

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 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="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
<ns uri="http://www.w3.org/1999/xhtml" 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.

Radu Coravu
<oXygen/> XML Editor

Posts: 10
Joined: Sun Apr 01, 2012 1:17 pm

Re: NVDL and custom XHTML 5

Post by ari » Mon Apr 07, 2014 6:33 pm

@Radu, thank you this is exactly what I was looking for.

Post Reply