Before you start
Here's what to expect from this tutorial, and how to get the most out of it.
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, by the needs of 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 a 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.
The objectives for this tutorial series are addressed in the following manner:
Part 1 (Go directly to Part 1 now.)
- 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.
- 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
- Transform the updated XML files to HTML.
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.
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.