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
|