JNVDL extensions are invoked using elements or attributes from
namespace http://jnvdl.sf.net
. The following text assumes
that prefix jnvdl
has been declared for this
namespace.
By default NVDL supports dispatching based on namespace and optionally based on element names. But there are situations when you have to use different schema for elements in the same namespace. Distinction has to be made also on other criterias then it is namespace.
The dispatching semantic is modified as follows. Dispatching is done only when namespace matches and at least one of the additional JNVDL conditions matches.
Can contain arbitrary XPath expression. Matches when expression returns true (or result that can be converted to true – i.e. nonempty nodeset or string). Expression is evaluated with the corresponding element section as a context node. For attribute sections dummy element is considered to be a context node.
Example 1. Example of jnvdl:useWhen
<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" xmlns:jnvdl="http://jnvdl.sf.net"> <namespace ns="http://www.w3.org/1999/XSL/Transform" jnvdl:useWhen="@version = '1.0'"> <validate schema="xslt1.xsd"/> </namespace> <namespace ns="http://www.w3.org/1999/XSL/Transform" jnvdl:useWhen="@version = '2.0'"> <validate schema="xslt2.rng"/> </namespace> </rules>
Matches when element section corresponds to a document node with a specified public identifier.
Example 2. Example of jnvdl:useWhenPublicId
<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" xmlns:jnvdl="http://jnvdl.sf.net"> <namespace ns="http://www.w3.org/1999/xhtml" jnvdl:useWhenPublicId="-//W3C//DTD XHTML 1.0 Strict//EN"> <validate schema="strict.rng"/> </namespace> <namespace ns="http://www.w3.org/1999/xhtml" jnvdl:useWhenPublicId="-//W3C//DTD XHTML 1.0 Transitional//EN"> <validate schema="transitional.rng"/> </namespace> </rules>
Matches when element section corresponds to a document node with a specified system identifier.
Example 3. Example of jnvdl:useWhenSystemId
<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" xmlns:jnvdl="http://jnvdl.sf.net"> <namespace ns="http://www.w3.org/1999/xhtml" jnvdl:useWhenSystemId="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <validate schema="strict.rng"/> </namespace> <namespace ns="http://www.w3.org/1999/xhtml" jnvdl:useWhenSystemId="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <validate schema="transitional.rng"/> </namespace> </rules>
Matches when element section corresponds to a document node with a specified public identifier. Value of this attribute is not treated as a plain text but as a regular expression.
Example 4. Example of jnvdl:useWhenPublicIdRegex
<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" xmlns:jnvdl="http://jnvdl.sf.net"> <!-- HTML 4.0, 4.01 and XHTML 1.0 Strict --> <namespace ns="http://www.w3.org/1999/xhtml" jnvdl:useWhenPublicIdRegex="-//W3C//DTD X?HTML (1\.0|4\.01?)( Strict)?//EN"> <validate schema="strict.rng"/> </namespace> </rules>
This attribute specifies prefix that should be used for elements from namespace of this section. JNVDL will modify section before dispatching to validation. All qualified element and attributes names belonging to the namespace of section are changed to use specified prefix. Namespace declarations are also modifed. If the value is empty, namespace prefixes are removed and default namespace is used instead.
This operation is very brutal, but allows you to use legacy DTDs with compound documents.
Example 5. Example of jnvdl:usePrefix
<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" xmlns:jnvdl="http://jnvdl.sf.net"> <namespace ns="http://www.w3.org/1999/xhtml" jnvdl:usePrefix=""> <validate schema="html.dtd"/> </namespace> </rules>
In this case prefixes from elements in XHTML namespace will be removed prior validation.
Example 6. Example of jnvdl:usePrefix
<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" xmlns:jnvdl="http://jnvdl.sf.net"> <namespace ns="http://www.w3.org/2000/svg" jnvdl:usePrefix="svg"> <validate schema="svg.dtd"/> </namespace> </rules>
In this case prefixes on SVG elements will be modified to svg:
.