DeltaXML.com - Change Control For XML, In XML.(spacer) Home    About Us    Contact Us    Search
(spacer)

Doctype Preservation Example

Introduction

This code demonstrates how DOCTYPE information can be detected at the start of a pipeline and reinserted at the end. This is because the DeltaXML components, as with other JAXP components are not designed to preserve DOCTYPE information.

Although this demonstration uses an artificial 3 stage XSLT filter pipeline the approach applies equally to pipelines using DeltaXML comparator and sync components. In the cases where DeltaXML components are used, extra application logic may be needed to decide what to do if different inputs have different DOCTYPEs or perhaps different systemId URIs.

Application logic should also be able to handle issues associated with relative URIs. Consider the case where the input files have a systemId of: ../lang.dtd, and the output file is located in a subdirectory relative to the input file, for example: subdir/output.xml. Either the input URL(s) could be made absolute, or 're-relativized' to something like: ../../lang.dtd. Again this would be application dependent.

The supplied Ant script can be used to compile and run the demonstration. Two input files are provided:

  • strict.xml
  • transitional.xml

using the XHTML doctype corresponding to their filenames. When run the output files:

  • strict-out.xml
  • transitional-out.xml

should use DOCTYPEs corresponding to the input files.

Compile and Run

Please use the provided Ant script, or for Windows Systems with J2SE 1.4.x, use the following commands:

Compile:
  javac DoctypePreserver.java

Run:
  java -cp ../saxon.jar;. DoctypePreserver strict.xml strict-out.xml
  java -cp ../saxon.jar;. DoctypePreserver transitional.xml transitional-out.xml

Manifest

README.txt

This file

build.xml

Ant script for compilation, running, tidyup

DoctypePreserver.java

Pipeline source code

stage1.xsl

Stage 1 XSLT source

stage2.xsl

Stage 2 XSLT source

stage3.xsl

Stage 3 XSLT source

strict.xml

Example data with XHTML Strict DOCTYPE

transitional.xml

Example data with XHTML Transitional DOCTYPE

 (spacer)Copyright © 2000-2005 DeltaXML Ltd, Malvern, UK. All rights reserved.
info@deltaxml.com