DocumentID: ECMA-376/Part5/AnnexA Title: ECMA-376, Part5: Annex A. Validation Using NVDL Extracted-From: ECMA-376 Office Open XML File Formats, 1st Edition / December 2006 Warning: Coverted to HTML format by a script known to have bugs
This annex is informative.
Namespace-based Validation Dispatching Language (NVDL) allows documents to be decomposed into validation candidates, each of which may be validated independently.
NVDL may be used for validation against the normative requirements of this Part. It may also be used for validation against the combination of Office Open XML documents (including the elements and attributes defined in this Part) and any extensions.
A markup document may satisfy requirements of this Annex without being an Office Open XML document. The following NVDL script examines whether a given document correctly uses the attributes and elements as defined by this Part.
This NVDL script first extracts elements and attributes in the Markup Compatibility namespace, and then validates them against the appropriate RELAX NG schemas.
Note that AlternateContent, Choice and Fallback elements are allowed to have foreign elements and attributes.
<?xml version="1.0" encoding="UTF-8"?>
<rules xmlns="">
<namespace match="attributes" ns="
">
<validate schemaType="application/relax-ng-compact-syntax">
<schema>
namespace mc="
"
nsList = list { xsd:NCName* }
qnameList = list { (xsd:QName | xsd:string {pattern = "\i\c*:\*" })*}
start = element * {
attribute mc:Ignorable { nsList }?,
attribute mc:ProcessContent { qnameList }?,
attribute mc:PreserveElements { qnameList }?,
attribute mc:PreserveAttributes { qnameList }?,
attribute mc:MustUnderstand { nsList }?
}
</schema>
</validate>
</namespace>
<namespace match="elements" ns="
">
<validate schemaType="application/relax-ng-compact-syntax">
<schema>
default namespace ="
"
nsList = list { xsd:NCName* }
qnameList = list { (xsd:QName | xsd:string {pattern = "\i\c*:\*" })*}
start = element AlternateContent {choice+,fallback?}
choice = element Choice {attribute Requires { nsList }, text}
fallback = element Fallback {text}
</schema>
</validate>
</namespace>
<namespace ns="" match="attributes">
<attach/>
</namespace>
<anyNamespace match="elements attributes">
<allow/>
</anyNamespace>
</rules>
The two RELAX NG schemas embedded in the above NVDL script may be rewritten in the analogous XML Schema form.
An extension of Office Open XML specified using the mechanisms defined in this Part may be captured by an NVDL script that invokes the Office Open XML schema and schemas for the extension.
The following schema allows two extensions. They have the namespaces and . The first extension is accompanied with a parent AlternateContent element and a sibling Fallback element, while the second one may appear anywhere in the document without AlternateContent or Fallback elements.
<?xml version="1.0" encoding="UTF-8"?>
<rules xmlns="" startMode="top">
<mode name="top">
<namespace
ns="">
<validate schema="wml.xsd" useMode="nested"/>
</namespace>
</mode>
<mode name="nested">
<namespace match="attributes elements"
ns="">
<attach/>
</namespace>
<namespace match="attributes elements"
ns="">
<attach/>
</namespace>
<namespace match="attributes elements"
ns="">
<attach/>
</namespace>
<namespace match="attributes elements"
ns="">
<attach/>
</namespace>
<namespace match="attributes elements"
ns="">
<attach/>
</namespace>
<namespace match="attributes elements"
ns="">
<attach/>
</namespace>
<namespace match="attributes elements"
ns="urn:schemas-microsoft-com:*">
<attach/>
</namespace>
<namespace match="attributes"
ns="">
<validate schemaType="application/relax-ng-compact-syntax">
<schema>
namespace mc =
"
"
nsList = list { xsd:NCName* }
qnameList = list { (xsd:QName | xsd:string {pattern =
"\i\c*:\*" })*}
start = element * {
attribute mc:Ignorable { nsList }?,
attribute mc:ProcessContent { qnameList }?,
attribute mc:PreserveElements { qnameList }?,
attribute mc:PreserveAttributes { qnameList }?,
attribute mc:MustUnderstand { nsList }?
}
</schema>
</validate>
</namespace>
<namespace match="elements"
ns="">
<validate schemaType="application/relax-ng-compact-syntax">
<schema>
default namespace =
"
"
nsList = list { xsd:NCName* }
qnameList = list { (xsd:QName | xsd:string {pattern =
"\i\c*:\*" })*}
start = element AlternateContent {choice,fallback}
choice = element Choice {attribute Requires { nsList },
text}
fallback = element Fallback {text}
</schema>
<mode>
<anyNamespace>
<allow/>
</anyNamespace>
</mode>
<context path="Choice">
<mode>
<namespace
ns="">
<validate schema="myExtensionWithFallback.rng">
<mode>
<anyNamespace>
<attach/>
</anyNamespace>
</mode>
</validate>
</namespace>
</mode>
</context>
</validate>
<unwrap>
<mode>
<anyNamespace>
<allow/>
</anyNamespace>
</mode>
<context path="Fallback">
<mode>
<anyNamespace>
<attach/>
</anyNamespace>
</mode>
</context>
</unwrap>
</namespace>
<namespace ns="">
<validate schema="myExtensionWithoutFallback.rng">
<mode>
<anyNamespace>
<attach/>
</anyNamespace>
</mode>
</validate>
</namespace>
</mode>
</rules>
End of informative text.