mj2008
mj2008

Reputation: 6747

What is best practice for defining extensions in an XML standard?

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?

Upvotes: 3

Views: 246

Answers (1)

John Saunders
John Saunders

Reputation: 161783

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.

Upvotes: 1

Related Questions