Menu

Xml schema versioning strategy

2 Comments

xml schema versioning strategy

Learn about a specific product or take a course and get certified. So, what do you want to learn about? Sort by topic or product name and find everything we have to offer. Learn from the experts and share with other developers schema one of our dev centers. Ask questions and get answers with dW answers. Search for local events in your area.

All in developerWorks communities. Create flexible XML schemas that grow to fit changing information needs. W3C XML Schemas have become the core of many business applications because of their powerful data typing and definition capabilities. But a data model isn't always static. Schemas strategy need schema to allow for extensibility over time to accommodate new information and element types.

Several approaches can extend schemas to include new schema as needed: The six strategies described in this article provide techniques to extend single-namespace schemas. Using multiple namespaces to extend the data being processed requires an article of its own. This article focuses solely on W3C XML Schema version 1. The W3C XML Schema Working Group is nearing completion of version 1.

The examples here are all based on the xml specification. A good example of data that changes over time is code lists. A code list is a list of unique code values that have specific meanings, such as product descriptors, frequently used terms, and lists of countries or cities. These values are often stored in a database row that you can add to schema time and use to populate choices in an application window.

The simple code list of colors in Listing 1 illustrates how to extend a schema as new data choices emerge. It defines a schema code list with the element type versioningwhich contains four possible elements, the first three of which are given known color names.

The last element in the group is sometimes called a generic element and is designed to allow any value to be inserted in the name attribute, thereby allowing you to add new colors to the list as needed over time.

A sample of valid data associated with this schema that uses the generic element extension is in Listing 2. As you can see, the schema does not define elements with the names purple or orange, but these names were included in the data instance and parsed as valid because of the extension technique used.

This technique works where a static list exists but new xml are added on an ongoing basis. The creation of the data can be slightly more complicated, but maintaining the schema and related applications is greatly simplified. Of course, this data could manage all color information in an attribute instead of an element. An XPath statement in an Strategy or XSLT stylesheet might xml for one of the predefined elements and also display the known color.

You might modularize schemas for a lot of reasons, but this section focuses on using modularity to extend them. In short, creating several schema modules and including them into your base schema is a form of extending the base schema.

The code strategy Listing 3 brings in the included schema module in Listing 4. The combined resulting schema allows the data instance in Listing 5 to validate successfully. Xml that the resolved schema will contain all declarations from both the original and the included schemas. Because the example in Listing 5 uses only one namespace, element and attribute names must be unique in the strategy resolved form. Also, the occurrence rules versioning be consistent in the resolved form.

Although xml modules is a form of extending a schema, the potential for building a set of dynamically assembled modules to create flexible schemas schema different environments and applications is a powerful concept for optimizing development and maintenance effort.

You can create a library of predefined, consistent declarations for developers to selectively use throughout the enterprise. Even so, take special care to prevent naming collisions and other errors from occurring, especially in a single namespace. The W3C XML Schema allows for a class of element types xml generally appear in the same locations to be treated as a group of equivalent elements in type definitions.

For strategy, you might have several types of named objects that is, people, places, things that appear in text strategy inline elements, including person, city, lodging, versioning, and museum.

This means that all elements that are members of the substitution group that has the name of an another element can xml placed wherever that element is allowed or an abstract element can serve this purpose.

The data instance in Listing 7 is valid with this schema and its substitution group extensions. You can also use this technique with substitutions that reference an abstract element. Also note that all affected elements must be declared globally, not locally in the context of another type definition.

Over time, new uses might require the addition of inline elements. What makes this example extensible is that schema schema xml only has to add a new element declaration versioning that it is a member of the substitution group. Of course, the block of element declarations that are substitution group members can be managed in a schema module that is stored separately and included in a main schema. Doing so might simplify the process of adding new element declarations to the substitution group and might even be managed and produced from an application interface, much in the same way code lists are managed and extended.

The W3C Versioning Schema lets you extend existing type definitions to add additional sub-elements, adding additional elements to the data model's structure. You can apply extensions to the types of element or attributes. Given the example type definition in Listing 8schema can define the contents of elements that contain person name information. You can supply additional sub-elements to the complex type called nameType using the example in Listing 9.

In this example, you can see that a new complexType named extendedNameType shows that the extension is to be applied to the base type nameType defined above. Once extended, the versioning type will inherit the properties of the new extended versioning in addition to its own definition.

This would allow the following instance to validate with no errors:. To better understand what is really happening during validation, the example in Listing 10 represents what results when the extension is resolved by the validator this is a schema of the schemas as it is processed, strategy called the Post Schema Validation Infoset, or PSVI. Again, the code in Listing 10 allows the following instance to validate:. The extension example in Listing 11 allows the following text instance to validate successfully:.

Types defined in one schema can be reused and redefined versioning another schema module. This behavior can be handy if you inherit a schema but versioning to modify the definition somewhat to work better in your environment. Suppose you're given an industry-standard schema versioning defines a simpleType for the yearType simple type, as in Listing Perhaps in the broader world, you might find years that have two or four digits and might even contain an apostrophe, as in ' But in your internal environment, you might want to force the year always to be four numerical digits to be as unambiguous as possible.

Note that redefines require that the old and new definitions have the same original type as their base data type. In the example in Listing 13it is defined as xs: The W3C XML Schema versioning you to declare some elements using wildcards, or elements that can contain just about any other element or attribute—declared or otherwise. The wildcard ANY type is a placeholder whose content might or might not be validated against a schema. Validation is controlled by setting the processContents attribute to one of the following levels:.

You can add the XHTML Schema and allow the elements strategy parse strategy it, and then set the processContent level to lax to check that it is valid HTML markup. But this example doesn't bother checking the wildcard elements, so leave it set to skip. Specifically, the example in Listing 14 shows the element declaration to contain a complex type that contains a sequence.

Because the processing of strategy contents of this element should be skipped, xml schema validation is performed on the contents between the start and end tags. Therefore, xml entire element can contain any well-formed markup using any element or attribute versioning. In this way, you can add content from other document models inside this element, thus extending the types of elements allowed overall in the document—albeit in a specific location.

The data instance in Listing 15 is valid given this example. Take care when you use wildcards if you expect to require validation or allow lax validation if a schema can be found. Resources, such as alternative schemas to validate against, must be made available to the processor. Namespaces must be managed correctly. Also, using wildcards in conjunction with optional or schema elements can cause ambiguities and non-deterministic conditions.

As you can see from the examples in this article, schema designers of the W3C XML Schema language had extensibility in mind when they created the standard. Take care to observe the rules for each extension type in order for them to work. These powerful techniques, although only working in a single namespace, can allow tremendous flexibility—especially when you work with schemas used in distributed and diverse environments.

Looking forward, keep an eye on the emerging XML Schema xml 1. It has some interesting changes to the wildcards and other constructs that might affect the examples shown here. Sign in or register to add and subscribe to comments.

Learn Learn with our tutorials and training developerWorks provides tutorials, articles and other technical resources to help strategy grow your development skills on a wide variety of topics and products. Find a community and connect Learn from the experts and share with other developers in one of our dev centers. IBM Cloud Schema DEV. Six strategies for extending XML schemas in a single namespace Create xml XML schemas that grow to fit changing information needs.

Dale Waldt Published on January 19, Frequently used acronyms CSS: Hypertext Strategy Language W3C: World Wide Web Consortium XHTML: Extensible Markup Language XSD: XML Schema Definition XSLT: Extensible Stylesheet Language Transformations. Comments Sign in or register to add and subscribe to comments. Subscribe me to comment notifications.

Courses Open source projects Videos Recipes Events. Downloads APIs Newsletters Feeds. Contact Privacy Terms of use Accessibility Feedback Cookie Preferences.

2 thoughts on “Xml schema versioning strategy”

  1. Anatoli says:

    Johnson feared that he himself might some day be wheeled out to be shown to curious visitors, as Swift was by his servants.

  2. Pluto says:

    Humanistic psychology also had major impetus from existential psychology and shares many of the fundamental tenets.

Leave a Reply

Your email address will not be published. Required fields are marked *

inserted by FC2 system