uk.ac.starlink.util
Class MultiXML

java.lang.Object
  extended byuk.ac.starlink.util.MultiXML

public class MultiXML
extends Object

Utility class which takes a single XML file and writes it out to a number of new XML/HTML files. Each <filesection> element in the file is written to a new file, with the name taken from the filesection's file attribute. Anything outside of a filesection is ignored. Filesection elements should not be nested.

Other attributes of the filesection element are used to set output properties for the XML transformation:

file
Name for the output file.
method
type of output ("xml", "html" or "text")
doctype-system
System ID for the HTML/XML declaration
doctype-public
Public ID for the HTML/XML declaration
indent
Whether the processor may prettyprint ("yes"/"no")
These attribute names and values match those in XSLT's xsl:output element.

This class is intended for use when you are doing an XSLT-based transformation which you would like to produce multiple output files from a single input file.

Since:
9 Mar 2004

Constructor Summary
MultiXML()
          Default constructor.
 
Method Summary
 Map getParams()
          Returns the map of parameters which will be used to affect the stylesheet transformation.
static void main(String[] args)
          Runs the transformation.
 void run()
          Performs the transformation in accordance with the current attributes of this object.
 void setDestdir(String destdir)
          Sets the name of the directory to which files should be output.
 void setIn(String in)
          Sets the location of the input XML file.
 void setStylesheet(String stylesheet)
          Sets the location of a stylesheet which is to be used to process the input file before the splitting is done.
 void setVerbose(int verbose)
          Sets the verbosity level - 0, 1 or 2 for ascending amounts of verbosity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiXML

public MultiXML()
Default constructor.

Method Detail

main

public static void main(String[] args)
                 throws IOException,
                        TransformerException,
                        SAXException,
                        ParserConfigurationException
Runs the transformation. Usage is
   MultiXML [-verbose] [-style sheet] 
            [-param name=value [-param name=value] ...]
                  infile outdir
 
Where:
-verbose
prints the name of each file as it is written
-style sheet
specifies the system id of an XSLT stylesheet with which to process the infile prior to doing the split
-param name=value
defines a parameter for use in the stylesheet transformation if there is one (may be used multiple times)
infile
the system id of the input XML file
outdir
directory into which output files will be written

Parameters:
args - command-line arguments
Throws:
IOException
TransformerException
SAXException
ParserConfigurationException

setVerbose

public void setVerbose(int verbose)
Sets the verbosity level - 0, 1 or 2 for ascending amounts of verbosity.

Parameters:
verbose - verbosity level

setDestdir

public void setDestdir(String destdir)
Sets the name of the directory to which files should be output.

Parameters:
destdir - output directory

setIn

public void setIn(String in)
Sets the location of the input XML file.

Parameters:
in - input file system id - may be "-" or null for standard input

setStylesheet

public void setStylesheet(String stylesheet)
Sets the location of a stylesheet which is to be used to process the input file before the splitting is done. May be null if the input file doesn't need further processing (already contains filesection elements).

Parameters:
stylesheet - XSLT stylesheet system id

getParams

public Map getParams()
Returns the map of parameters which will be used to affect the stylesheet transformation. Only effective if the stylesheet has been set at run time.

Returns:
modifiable parameter map

run

public void run()
         throws IOException,
                TransformerException,
                SAXException,
                ParserConfigurationException
Performs the transformation in accordance with the current attributes of this object.

Throws:
IOException
TransformerException
SAXException
ParserConfigurationException

Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved.