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:  

Before you start

Learn what to expect from this tutorial, and how to get the most out of it.

About this tutorial

If you're responsible for maintaining a library of schema-based XML, it's likely that the schema upon which the files are based has been updated over time. The schema updates might have been necessary because of updated internal standards at your company or because of the need for your business to carry less, different, or more information within the XML files.

Whatever the cause of the schema updates, you'll want to seriously consider updating all of your XML files whenever the schema is updated so that they all validate against the current schema. By doing so, the task of processing the XML files is made easier than if the XML files conformed to several schemas. Why? If every file conforms to the same schema, you only have to write one version of code to process those XML files (in this tutorial, it'll be XSLT stylesheets) because it can assume a homogeneous XML structure across the entire library of files. Mass conformance to one schema is especially important if your new schema incorporates renamed, added, or removed required elements or attributes.

Updating few XML files by hand is no problem. But what if you have hundreds, or thousands, of XML files to update? A programatic solution is required. This tutorial will help you tackle the XML file updates with a methodology that has been proven many times by the developerWorks staff.


Objectives

The objectives for this tutorial series are addressed in the following manner:

Part 1

  • Review a checklist for the entire process.
  • Create a conversion stylesheet -- an XSLT stylesheet with templates to add, update, and delete elements and attributes in existing XML files so that the files conform to a new XML schema.

Part 2 (Go directly to Part 2 now.)

  • Install and configure Ant and Java SE.
  • Using Ant, iteratively update and validate each of your XML files based on the updates specified in your XSLT stylesheet, and then transform them again to HTML.

Prerequisite knowledge

To get the most from this tutorial, you should be able to create XML schemas (or document type definitions, also known as DTDs) and XSLT stylesheets. See Resources for developerWorks articles and tutorials that will help you learn these skills.


System requirements

To process the sample code supplied with this tutorial, install the following software on your computer:

  • Microsoft Windows 2000 or later.
  • A Web browser.
  • A validating XML editor for editing XML schemas, XML instance documents, and XSLT stylesheets.
  • The Apache Software Foundation's Ant software.
  • J2SE™ or J2EE™ (Runtime Environment or Development Kit) 1.2 or higher is required by Ant. Version 1.4 is recommended because it comes with an XSL transformer; therefore, you won't have to download and install Xalan-Java separately, for example. Note: Ant does not support the Microsoft JVM/JDK.

See Resources for more information.

1 of 10 | 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=