tags:

views:

47

answers:

1

I'm working on an XML Schema which is going to be used for data transfer between a number of applications, not all under our control. The core data is going to be the same for all, but we want to allow specific applications to store additional data to allow "round-tripping" of the files so they can save and reload and not lose anything that is specific to that app. What is the best practice for this?

The thoughts we have so far are to define an node for each main node, which will allow us to validate against a schema (no unexpected nodes, or nodes in the wrong place), which allowing anything to be stored under the Extension node.

It is likely that we will also want to define one or more of these extended schemas as schemas in their own right.

How is this done in other standards please? What should we adopt?

+1  A: 

If the original schema was not written for extensibility, then you're out of luck.

As an example of a schema written for extensibility, see the schema for WSDL. Note that just about everything extends the wsdl:documented type. Note that many elements also permit extensibility:

<complexType name="serviceType">
    <complexContent>
        <extension base="wsdl:documented">
            <sequence>
                <element ref="wsdl:port" minOccurs="0" maxOccurs="unbounded"/>
                <any namespace="##other" minOccurs="0"/>
            </sequence>
            <attribute name="name" type="NCName" use="required"/>
        </extension>
    </complexContent>
</complexType>

The any element will permit arbitrary XML to be included.


BTW, everything I know about XML schema, I learned from XML Schema by Eric van der Vlist.

Publisher: O'Reilly Media, Inc.
Pub Date: June 25, 2002
Print ISBN-13: 978-0-596-00252-7
Pages: 400

See Chapter 13, Creating Extensible Schemas.

John Saunders
We are designing the schema ourselves, so can make it do anything we want at this point in time.
mj2008
Sorry, I missed where you said "going to". If you follow the example of the WSDL schema, you'll get far.
John Saunders
See my edit for a book recommendation.
John Saunders
Also see pp95- on the impact of the deterministic content model requirement of XSD. Also for attributes, xsd:anyAttribute can be used.
Richard