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 profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

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]

developerWorks Community:

  • Close [x]

Automate XML file updates, Part 1: XML process introduction and conversion stylesheet creation

A methodology using XSLT, Apache Ant, and Java SE

Tom Coppedge (tcoppedg@us.ibm.com), developerWorks Software Engineer, IBM
Tom Coppedge has been a member of the developerWorks design team since the site was launched in 1999. Tom's focus includes XML & XSLT strategy, information architecture, and site design. He joined IBM in 1988 after receiving a degree in Information Systems & Operations Management from the University of North Carolina at Greensboro.

Summary:  This is the first part of a tutorial series that describes a method for automating updates to a library of XML files so that they all conform to an updated XML schema. In Part 1, you learn the steps in the entire process and then create an XSLT stylesheet to update the XML files. In Part 2, you learn how to install, configure, and run Apache Ant and Java SE to iteratively transform each of your XML files based on the updates specified in your XSLT stylesheet.

View more content in this series

Date:  17 Aug 2006
Level:  Intermediate PDF:  A4 and Letter (303 KB | 15 pages)Get Adobe® Reader®

Activity:  13991 views
Comments:  

Determine whether an XML file update is required

Some schema updates will require you to update your XML instance documents to ensure they conform to the new schema. Other updates require no action and can be ignored.

The following checklist will help you to determine the types of schema updates that will need to be reflected in your XML files. Note: Updates can affect elements, attributes, simpleTypes, complexTypes, and groups; the schema update descriptions in the table apply to any of these constructs.


Table 2: Schema updates requiring XML instance document updates
Schema update descriptionAction required
Updates to constructs (elements, attributes, simpleTypes, complexTypes, groups)
A required construct was addedYou must add the new required construct to the XML instance documents.
An optional construct was addedNo action is required. If you have data values for the optional construct that could be used, you might consider adding the new construct to the XML instance documents if you have time.
A required or optional construct was removedYou must remove the construct from the XML instance documents.
A previously required construct is now optionalNo action is required.
A previously optional construct is now requiredYou must add the new required construct to those XML instance documents that don't already have it.
A construct was renamed or resequencedYou must rename or resequence the construct within the XML instance documents that contain it.
Updates to construct data values (values of elements, attributes, simpleTypes, complexTypes, groups)
A data value was added to an enumeration listNo action is required.
A data value was deleted from an enumeration listYou must delete that value wherever it occurs in your XML instance documents. If the construct with this data value is required, you must determine an acceptable data value to be used instead of the old one.
A data value has been changed in an enumeration listYou must change that value accordingly wherever it occurs in your XML instance documents.
General note: If an update affects a simpleType or complexType construct, the elements or attributes based on this construct might also be affected. For example, if three elements get their definition from the same complexType construct, and the complexType definition was updated with a new required attribute, then those three elements must be updated with the new attribute wherever they appear in your XML documents.

If you have multiple XML instance documents that adhere to different versions of the schema (or different schemas), you'll need to address the possible differences between the updated schema and the other versions. Imagine that situation for a minute. It shouldn't take long for you to see the benefit of keeping all the XML documents compliant with the same (current) schema when schema updates are necessary.

By applying this checklist to each schema update you listed in the previous step, you have the basis for creating the XSLT stylesheet templates necessary to update your XML instance documents.

4 of 10 | Previous | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Web development, XML
ArticleID=153748
TutorialTitle=Automate XML file updates, Part 1: XML process introduction and conversion stylesheet creation
publish-date=08172006
author1-email=tcoppedg@us.ibm.com
author1-email-cc=