W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2009

[XML Schema 1.1] Does defaultOpenContent allow me to add extension elements before and after the root element?

From: Costello, Roger L. <costello@mitre.org>
Date: Thu, 4 Jun 2009 15:49:15 -0400
To: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Message-ID: <9E51F88D5247B648908850C35A3BBB5003FD40C197@IMCMBX3.MITRE.ORG>

Hi Folks,

Consider this schema, which uses <defaultOpenContent> to make the entire schema open:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="http://www.books.org"
           xmlns="http://www.books.org"
           elementFormDefault="qualified">

    <xs:defaultOpenContent mode="interleave">
        <xs:any />
    </xs:defaultOpenContent>

    <xs:element name="BookStore">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Book" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="Title" type="xs:string"/>
                            <xs:element name="Author" type="xs:string" />
                            <xs:element name="Date" type="xs:string"/>
                            <xs:element name="ISBN" type="xs:string"/>
                            <xs:element name="Publisher" type="xs:string"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

</xs:schema>


Can I add extension elements before and after the root element (BookStore)?


Is this instance document legal (I have wrapped the root element with an extension element):

<?xml version="1.0"?>
<r:MyFavoriteBookStore xmlns:r="http://www.bookrepository.org">
    <BookStore xmlns="http://www.books.org">
        <Book>
                <Title>My Life and Times</Title>
                <Author>Paul McCartney</Author>
                <Date>1998</Date>
                <ISBN>1-56592-235-2</ISBN>
                <Publisher>McMillin Publishing</Publisher>
                <r:Binding>Hardcover</r:Binding>
        </Book>
        <Book>
                <r:Size>5 x 7</r:Size>
                <Title>Illusions The Adventures of a Reluctant Messiah</Title>
                <Author>Richard Bach</Author>
                <Date>1977</Date>
                <ISBN>0-440-34319-4</ISBN>
                <Publisher>Dell Publishing Co.</Publisher>
        </Book>
        <Book>
                <Title>The First and Last Freedom</Title>
                <Author>J. Krishnamurti</Author>
                <r:NumPages>299</r:NumPages>
                <Date>1954</Date>
                <ISBN>0-06-064831-7</ISBN>
                <Publisher>Harper &amp; Row</Publisher>
        </Book>
    </BookStore>
</r:MyFavoriteBookStore>

/Roger
Received on Thursday, 4 June 2009 19:49:50 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:15:12 GMT