Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Compound XML document profiles for rich content, Part 2: A pattern for developing compound XML document schemas

Steve Speicher (sspeiche@us.ibm.com), Senior Software Engineer, IBM
Steve Speicher is a Senior Software Engineer with IBM working on Software Standards. Steve's current focus is leveraging tools and model-driven development to improve the process of creating standards. Steve has previously worked on software development tools in the Rational division and IBM internal tools. Steve holds a B.S. in Computer Science and Applied Mathematics, both from Kent State University. Contact Steve at sspeiche@us.ibm.com.
Kevin E. Kelly (kekelly@us.ibm.com), Senior Software Engineer, IBM
Kevin E. Kelly is a Senior Software Engineer with IBM working on software standards. Kevin is a member of the W3C XForms Working Group and the Chair for the W3C Compound Document Format Working Group. His focus is on the client technology and evolving open standards-based technologies for faster, more efficient standards adoption through XML-based and model-driven approaches. Before joining IBM, Kevin spent eight years at Rational software working on UML modeling and Java technologies. Kevin holds a B.S. from Mercer University and a M.S. from the University of Montana. Contact Kevin at kekelly@us.ibm.com.

Summary:  Build compound XML Schema profiles from core specification schemas. Part 1 of this two-part series explores several extension capabilities of XML Schema and compares approaches in building Compound Document Format (CDF) profiles. This article defines a pattern for developing mixed-namespace profiles using XML Schema, based on the analysis in Part 1.

Date:  21 Sep 2005
Level:  Advanced

Activity:  7148 views
Comments:  

Overview

User demand for rich Web application content is continually increasing for both desktop and mobile device platforms. Open, standards-based functional XML schemas enabling rich content help ensure that such content -- and the skills required to produce it -- remains ubiquitous, accessible, and cost effective. Schemas also help ensure that this technology does not become a proprietary format for a single or small number of vendors constrained to specific programming frameworks or to specific renderer and browser technologies.

XML-based, declarative functional schemas like XHTML, XForms, XML Events, Scalable Vector Graphics (SVG), SMIL, VoiceXML, and XHTML Mobile Profile are examples of schemas that provide specific functionality for creating rich content.

Each functional schema pertains to a specific area of functionality. For example, SVG addresses graphics; XForms addresses form input collection and submission; XML Events addresses the creation of events and listeners; and so on. However, most rich Web applications require a combination of two or more of these functional schemas within a single document. Combining schemas can be problematic because not all schemas can be embedded within other schemas. And not all schemas allow other schemas to be embedded within themselves. In fact, most functional schemas assume that they are the root schema in a single document with only one functional namespace and that if the need arises for rich content from another functional namespace, a separate document can be referenced with its own root schema. For example, an XHTML document can reference an SVG graphic in a separate document at runtime to render the graphic.

Some schemas are written specifically to be embedded, such as XForms (which was never intended to be the root schema in a document). Other schemas have been adapted for embedding through the use of newer schemas that forge a combination of existing functional schemas (such as XHTML and VoiceXML's X+V profile). The XForms specification includes guidance for enclosing schemas, but an actual combining driver schema does not exist. In the case of X+V, a separate driver schema was created by copying the VoiceXML schema and replacing specific elements with XHTML schema elements.

There isn't much clear guidance for user agent developers or content creators about which tags from XForms are allowed under XHTML tags or which XHTML tags are then allowed under XForms tags.


Figure 1. Sample rendered compound document using XHTML, MathML, and SVG
Sidewinder screenshot

Defining profile schemas

A key element of this pattern is the use of a profile schema that provides the redefinitions that enable the creation, modification, and validation of compound XML documents. Using this approach, you can separate the desired combination of valid cross-namespace element combinations without violating the integrity of the core functional schemas. As an example of this, Part 1 outlines a simple compounding that enables XForms elements within an XHTML document, and likewise enables XHTML elements within XForms elements, as shown in Figure 2.


Figure 2. Sample of pattern for defining CDF profile schemas
Sample of pattern for defining CDF profile schemas

As you learned in Part 1, using XML Schema redefines gives you the flexibility you need to extend the core schemas.

You need at least one profile schema for each combination of namespaces. However, in some cases you may be able to create a single profile schema to redefine one schema while introducing more than one foreign namespace. We recommend using modularization and separating these redefinitions, because they may be useful independently or with other combinations.

Keep in mind that you can reuse these profile schemas to create bidirectional combinations or combinations with other namespaces.


Enabling core schemas for redefines

In the following subsections, we highlight recommendations for developing core schemas using redefines. These recommendations allow your core schemas to be easily redefined without being modified -- or, at least, help keep modifications to a minimum.

Using anonymous types (Don't!)

It's impossible to use an XML Schema redefine on a simple or complex declaration if it's done anonymously (within the context of the actual element/attribute declaration). Instead, you should expose these types by defining the content of the elements and let the element declaration reference the type.

This approach also enables better internal componentization and abstraction: You can define abstract and reusable parent types, and you can also make new extensions and restrictions.

Grouping items appropriately

When using redefine (and for good schema design in general), it is often desirable to define content models based on global group definitions. When you define element and attribute content using groups, you can easily extend the existing group definition to include additional items.

Defining global elements

When declaring an element outside the context of a type declaration or group, you need to be careful because the scope is global. This step also has the effect of enabling the element to be a valid root element in an instance document. This can misdirect generation tools to create documents with unintended root elements, at least from the point of view of the schema author. However, schema validation tools using the schema do not report a violation. So use global element declarations sparingly.

The use of global elements can prove useful, however, when elements from different namespaces are referenced within the complex content definition. This is the case in the example in Part 1, in which the global XHTML p element is added to the extended complex type definition for the XForms select element. Even so, the ideal solution is to reference a group declaration from the XHTML schema that includes a declaration of the p element.

Understanding naming conventions

Naming conventions, which exist for all types of programming languages, enable readers to quickly understand additional metadata about a language construct. Without such conventions, the reader must either research the language construct or depend on the tooling to provide visual indicators. These conventions can be quite useful in helping users understand differing core schema constructs. A recommended convention is one used in the XHTML modularization effort. (See Resources.)

Modularizing whenever possible

Although not a key aspect of this pattern, modularization can provide key benefits for the reuse, understanding, extensibility, and maintenance of schemas. For compound documents, modularization eases the construction of new schemas by providing a driver schema that includes and imports the appropriate modules. This driver schema can either be modified or redefined using the techniques explained in this article and in Part 1.


Looking at XHTML and XForms

As we mentioned in Part 1, the intent of this series is to explore high-level scenarios and design patterns for building robust and reusable schemas that define a solid validation framework for compound document content. The details on valid content and semantics are being codeveloped by the W3C's XHTML 2.0, XForms, and CDF Workings Groups. (See Resources.)


Summary

Following the pattern defined in this article, both standards designers and business data modelers can benefit from more reusable document and data models. They can also benefit from having a technique (pattern) for embedding other data models (schemas) and for being embedded by other data models. Designers often think that their root element will always be the root, but then later realize there are many valuable scenarios where their model needs to exist within other models.


Resources

Learn

Get products and technologies

Discuss

About the authors

Steve Speicher is a Senior Software Engineer with IBM working on Software Standards. Steve's current focus is leveraging tools and model-driven development to improve the process of creating standards. Steve has previously worked on software development tools in the Rational division and IBM internal tools. Steve holds a B.S. in Computer Science and Applied Mathematics, both from Kent State University. Contact Steve at sspeiche@us.ibm.com.

Kevin E. Kelly is a Senior Software Engineer with IBM working on software standards. Kevin is a member of the W3C XForms Working Group and the Chair for the W3C Compound Document Format Working Group. His focus is on the client technology and evolving open standards-based technologies for faster, more efficient standards adoption through XML-based and model-driven approaches. Before joining IBM, Kevin spent eight years at Rational software working on UML modeling and Java technologies. Kevin holds a B.S. from Mercer University and a M.S. from the University of Montana. Contact Kevin at kekelly@us.ibm.com.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=XML
ArticleID=94355
ArticleTitle=Compound XML document profiles for rich content, Part 2: A pattern for developing compound XML document schemas
publish-date=09212005
author1-email=sspeiche@us.ibm.com
author1-email-cc=clarkega@us.ibm.com
author2-email=kekelly@us.ibm.com
author2-email-cc=dwxed@us.ibm.com

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.

Special offers