Validation Against the Combination of Office Open XML and Extensions

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 http://www.example.com/myExtensionWithFallback and http://www.example.com/myExtensionWithoutFallback. 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="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" startMode="top">
    <mode name="top">
        <namespace  
          ns="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
            <validate schema="wml.xsd" useMode="nested"/>
        </namespace>
    </mode>
    <mode name="nested">
        <namespace match="attributes elements"
            ns="http://schemas.openxmlformats.org/drawingml/2006/*">
            <attach/>
        </namespace>
        <namespace match="attributes elements"
            ns="http://schemas.openxmlformats.org/officeDocument/2006/*">
            <attach/>
        </namespace>
        <namespace match="attributes elements"    
          ns="http://schemas.openxmlformats.org/package/2006/*">
            <attach/>
        </namespace>
        <namespace match="attributes elements"
            ns="http://schemas.openxmlformats.org/presentationml/2006/main">
            <attach/>
        </namespace>
        <namespace match="attributes elements"
            ns="http://schemas.openxmlformats.org/schemaLibrary/2006/main">
            <attach/>
        </namespace>
        <namespace match="attributes elements"
            ns="http://schemas.openxmlformats.org/spreadsheetml/2006/7/main">
            <attach/>
        </namespace>
        <namespace match="attributes elements" 
          ns="urn:schemas-microsoft-com:*">
            <attach/>
        </namespace>
        <namespace match="attributes"
            ns="http://schemas.openxmlformats.org/markup-compatibility/2006">
            <validate schemaType="application/relax-ng-compact-syntax">
                <schema>
                    namespace mc =
                    "http://schemas.openxmlformats.org/markup-
                      compatibility/2006"
                    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="http://schemas.openxmlformats.org/markup-compatibility/2006">
            <validate schemaType="application/relax-ng-compact-syntax">
                <schema>
                    default namespace =
                    "http://schemas.openxmlformats.org/markup-
                      compatibility/2006"
                    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="http://www.example.com/myExtenstionWithFallback">
                            <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="http://www.example.com/myExtensionWithoutFallback">
            <validate schema="myExtensionWithoutFallback.rng">
                <mode>
                    <anyNamespace>
                        <attach/>
                    </anyNamespace>
                </mode>
            </validate>
        </namespace>
    </mode>
</rules>