net.sf.kernow
Class Kernow

java.lang.Object
  extended by net.sf.kernow.Kernow

public class Kernow
extends java.lang.Object

A high level API for running transforms, XQueries and XML Schema validation.

To use Kernow's GUI use net.sf.kernow.GUI.


Constructor Summary
Kernow()
          Creates a new instance of Kernow
 
Method Summary
 boolean directoryTransform(java.lang.String inputDir, java.lang.String stylesheet, java.lang.String outputDir)
          Runs a directory transformation.
 boolean directoryTransform(java.lang.String inputDir, java.lang.String stylesheet, java.lang.String outputDir, java.util.HashMap<java.lang.String,java.lang.Object> params)
          Runs a directory transformation with parameters
 Config getConfig()
          Returns Kernow's configuration object.
 boolean runDirectoryTransform(java.lang.String inputDir, java.lang.String stylesheet, java.lang.String outputDir)
          Runs a directory transformation.
 boolean runDirectoryTransform(java.lang.String inputDir, java.lang.String stylesheet, java.lang.String outputDir, java.util.HashMap<java.lang.String,java.lang.Object> params)
          Runs a directory transformation with parameters
 boolean runSingleFileTransform(java.lang.String inputXML, java.lang.String stylesheet, java.lang.String outputFile)
          Runs a standard transformation without parameters
 boolean runSingleFileTransform(java.lang.String inputXML, java.lang.String stylesheet, java.lang.String outputFile, java.util.HashMap<java.lang.String,java.lang.Object> params)
          Runs a standard transformation with parameters
 boolean runStandaloneTransform(java.lang.String stylesheet, java.lang.String initialTemplate, java.lang.String outputFile)
          Runs a standalone transformation.
 boolean runStandaloneTransform(java.lang.String stylesheet, java.lang.String initialTemplate, java.lang.String outputFile, java.util.HashMap<java.lang.String,java.lang.Object> params)
          Runs a standalone transformation with parameters.
 boolean singleFileTransform(javax.xml.transform.Source inputXML, javax.xml.transform.Source stylesheet, javax.xml.transform.Result result)
          Runs a standard transformation without parameters
 boolean singleFileTransform(javax.xml.transform.Source inputXML, javax.xml.transform.Source stylesheet, javax.xml.transform.Result result, java.util.HashMap<java.lang.String,java.lang.Object> params)
          Runs a standard transformation with parameters
 boolean standaloneTransform(javax.xml.transform.Source stylesheet, java.lang.String initialTemplate, javax.xml.transform.Result result)
          Runs a standalone transformation.
 boolean standaloneTransform(javax.xml.transform.Source stylesheet, java.lang.String initialTemplate, javax.xml.transform.Result result, java.util.HashMap<java.lang.String,java.lang.Object> params)
          Runs a standalone transformation with parameters.
 boolean standaloneXQuery(java.lang.String xquery, javax.xml.transform.Result result)
          Runs a standalone XQuery (one with no input) and sends the result to the Result.
 boolean validateDirectory(java.io.File directory, javax.xml.transform.Source schema)
          Validate all files in a directory
 boolean validateFile(javax.xml.transform.Source xml, javax.xml.transform.Source schema)
          Validates the XML with the schema
 boolean validateSchema(javax.xml.transform.Source schema)
          Checks that schema compiles
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Kernow

public Kernow()
Creates a new instance of Kernow

Method Detail

getConfig

public Config getConfig()
Returns Kernow's configuration object. This is a singleton and should be used to set any options or switches prior to the transform.

Returns:
Kernow's config object

singleFileTransform

public boolean singleFileTransform(javax.xml.transform.Source inputXML,
                                   javax.xml.transform.Source stylesheet,
                                   javax.xml.transform.Result result,
                                   java.util.HashMap<java.lang.String,java.lang.Object> params)
Runs a standard transformation with parameters

Parameters:
inputXML - The input XML file
stylesheet - The XSLT to use
result - The Result of the transform
params - A HashMap of name value pairs to use as parameters
Returns:
Returns true if the transform was a success

singleFileTransform

public boolean singleFileTransform(javax.xml.transform.Source inputXML,
                                   javax.xml.transform.Source stylesheet,
                                   javax.xml.transform.Result result)
Runs a standard transformation without parameters

Parameters:
inputXML - The XML input to transform
stylesheet - The XSLT to use
result - The Result of the transform
Returns:
Returns true if the transform was a success

directoryTransform

public boolean directoryTransform(java.lang.String inputDir,
                                  java.lang.String stylesheet,
                                  java.lang.String outputDir,
                                  java.util.HashMap<java.lang.String,java.lang.Object> params)
                           throws java.net.URISyntaxException
Runs a directory transformation with parameters

Parameters:
inputDir - The input directory
stylesheet - The XSLT to use
outputDir - The output directory
params - A HashMap of name value pairs to use as parameters
Returns:
Returns true if all transforms are successful, false if any fail.
Throws:
java.net.URISyntaxException

directoryTransform

public boolean directoryTransform(java.lang.String inputDir,
                                  java.lang.String stylesheet,
                                  java.lang.String outputDir)
                           throws java.net.URISyntaxException
Runs a directory transformation.

Parameters:
inputDir - The input directory
stylesheet - The XSLT to use
outputDir - The output directory
Returns:
Returns true if all transforms are successful, false if any fail.
Throws:
java.net.URISyntaxException

standaloneTransform

public boolean standaloneTransform(javax.xml.transform.Source stylesheet,
                                   java.lang.String initialTemplate,
                                   javax.xml.transform.Result result,
                                   java.util.HashMap<java.lang.String,java.lang.Object> params)
Runs a standalone transformation with parameters. Standalone transforms don't have an input XML, instead processing starts at the named template specified by the "initial template" parameter.

Parameters:
stylesheet - The XSLT to use
initialTemplate - The name of the template where processing should start
result - The Result of the transform
params - A HashMap of name value pairs to use as parameters
Returns:
Returns true if the transform was a success

standaloneTransform

public boolean standaloneTransform(javax.xml.transform.Source stylesheet,
                                   java.lang.String initialTemplate,
                                   javax.xml.transform.Result result)
Runs a standalone transformation. Standalone transforms don't have an input XML, instead processing starts at the named template specified by the "initial template" parameter.

Parameters:
stylesheet - The XSLT to use
initialTemplate - The name of the template where processing should start The Result of the transform
Returns:
Returns true if the transform was a success

standaloneXQuery

public boolean standaloneXQuery(java.lang.String xquery,
                                javax.xml.transform.Result result)
Runs a standalone XQuery (one with no input) and sends the result to the Result.

Parameters:
xquery - The XQuery to execute The Result of the XQuery

validateSchema

public boolean validateSchema(javax.xml.transform.Source schema)
Checks that schema compiles

Parameters:
schema - The schema to compile
Returns:
true if the schema compiles successfully

validateFile

public boolean validateFile(javax.xml.transform.Source xml,
                            javax.xml.transform.Source schema)
Validates the XML with the schema

Parameters:
xml - The XML to validate
schema - The schema to validate the XML with
Returns:
true if the XML is valid according to the schema

validateDirectory

public boolean validateDirectory(java.io.File directory,
                                 javax.xml.transform.Source schema)
Validate all files in a directory

Parameters:
directory - The directory to validate
schema - The schema to validate the directory with
Returns:
true if all files in the directory are valid, false if any fail validation or there's an error

runSingleFileTransform

public boolean runSingleFileTransform(java.lang.String inputXML,
                                      java.lang.String stylesheet,
                                      java.lang.String outputFile,
                                      java.util.HashMap<java.lang.String,java.lang.Object> params)
                               throws java.net.URISyntaxException
Runs a standard transformation with parameters

Parameters:
inputXML - The input XML file
stylesheet - The XSLT to use
outputFile - The output file
params - A HashMap of name value pairs to use as parameters
Returns:
Returns true if the transform was a success
Throws:
java.net.URISyntaxException

runSingleFileTransform

public boolean runSingleFileTransform(java.lang.String inputXML,
                                      java.lang.String stylesheet,
                                      java.lang.String outputFile)
Runs a standard transformation without parameters

Parameters:
inputXML - The input XML file
stylesheet - The XSLT to use
outputFile - The output file
Returns:
Returns true if the transform was a success

runDirectoryTransform

public boolean runDirectoryTransform(java.lang.String inputDir,
                                     java.lang.String stylesheet,
                                     java.lang.String outputDir,
                                     java.util.HashMap<java.lang.String,java.lang.Object> params)
                              throws java.net.URISyntaxException
Runs a directory transformation with parameters

Parameters:
inputDir - The input directory
stylesheet - The XSLT to use
outputDir - The output directory
params - A HashMap of name value pairs to use as parameters
Returns:
Returns true if all transforms are successful, false if any fail.
Throws:
java.net.URISyntaxException

runDirectoryTransform

public boolean runDirectoryTransform(java.lang.String inputDir,
                                     java.lang.String stylesheet,
                                     java.lang.String outputDir)
                              throws java.net.URISyntaxException
Runs a directory transformation.

Parameters:
inputDir - The input directory
stylesheet - The XSLT to use
outputDir - The output directory
Returns:
Returns true if all transforms are successful, false if any fail.
Throws:
java.net.URISyntaxException

runStandaloneTransform

public boolean runStandaloneTransform(java.lang.String stylesheet,
                                      java.lang.String initialTemplate,
                                      java.lang.String outputFile,
                                      java.util.HashMap<java.lang.String,java.lang.Object> params)
                               throws java.net.URISyntaxException
Runs a standalone transformation with parameters. Standalone transforms don't have an input XML, instead processing starts at the named template specified by the "initial template" parameter.

Parameters:
stylesheet - The XSLT to use
initialTemplate - The name of the template where processing should start
outputFile - The primary output file
params - A HashMap of name value pairs to use as parameters
Returns:
Returns true if the transform was a success
Throws:
java.net.URISyntaxException

runStandaloneTransform

public boolean runStandaloneTransform(java.lang.String stylesheet,
                                      java.lang.String initialTemplate,
                                      java.lang.String outputFile)
Runs a standalone transformation. Standalone transforms don't have an input XML, instead processing starts at the named template specified by the "initial template" parameter.

Parameters:
stylesheet - The XSLT to use
initialTemplate - The name of the template where processing should start
outputFile - The primary output file
Returns:
Returns true if the transform was a success