ptolemy.util
Class XSLTUtilities

java.lang.Object
  |
  +--ptolemy.util.XSLTUtilities

public class XSLTUtilities
extends java.lang.Object

A collection of utilities for manipulating strings using XSLT These utilities do not depend on any other ptolemy.* packages.

Since:
Ptolemy II 2.1
Version:
$Id: XSLTUtilities.java,v 1.13 2003/04/28 06:50:38 cxh Exp $
Author:
Christopher Hylands, Haiyang Zheng

Method Summary
static void main(java.lang.String[] args)
          Read an input file and one or more xsl files and generate the output file java -classpath $PTII ptolemy.util.XSLTUtilities $PTII/ptolemy/hsif/demo/SwimmingPool/SwimmingPool.xml \ $PTII/ptolemy/hsif/xsl/GlobalVariablePreprocessor.xsl \ /tmp/SwimmingPool_1.xml
static org.w3c.dom.Document parse(java.lang.String filename)
          Parse a document.
static java.lang.String toString(org.w3c.dom.Document document)
          Given a Document, generate a String.
static org.w3c.dom.Document transform(org.w3c.dom.Document inputDocument, java.util.List xslFileNames)
          Transform a document.
static org.w3c.dom.Document transform(org.w3c.dom.Document inputDocument, java.lang.String xslFileName)
          Transform a document
static void transform(java.lang.String xsltFileName, java.lang.String sourceFileName, java.lang.String resultFileName)
          Transform a document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Read an input file and one or more xsl files and generate the output file
  java -classpath $PTII ptolemy.util.XSLTUtilities
       $PTII/ptolemy/hsif/demo/SwimmingPool/SwimmingPool.xml \
       $PTII/ptolemy/hsif/xsl/GlobalVariablePreprocessor.xsl \
       /tmp/SwimmingPool_1.xml
 

Throws:
java.lang.Exception - If there are problems with the transform.

parse

public static org.w3c.dom.Document parse(java.lang.String filename)
                                  throws java.lang.Exception
Parse a document.

Parameters:
filename - The file name of the xml file to be read in The filename is passed to org.xml.sax.InputSource(String), so it may be a file name or a URL.
Returns:
the parsed document.
Throws:
java.lang.Exception - Thrown if there is a problem with the transformation.

toString

public static java.lang.String toString(org.w3c.dom.Document document)
                                 throws java.lang.Exception
Given a Document, generate a String.

Parameters:
document - The document to be converted to a string.
Throws:
java.lang.Exception

transform

public static org.w3c.dom.Document transform(org.w3c.dom.Document inputDocument,
                                             java.lang.String xslFileName)
                                      throws java.lang.Exception
Transform a document

Parameters:
inputDocument - The Document to be transformed
xslFileName - The file name of the xsl file to be used. If the file cannot be found, then we look up the file in the classpath.
Returns:
a transformed document
Throws:
Thrown - if there is a problem with the transformation.
java.lang.Exception

transform

public static org.w3c.dom.Document transform(org.w3c.dom.Document inputDocument,
                                             java.util.List xslFileNames)
                                      throws java.lang.Exception
Transform a document.

Parameters:
inputDocument - The Document to be transformed
xslFileNames - A list of Strings naming the xsl files to be applied sequentially.
Returns:
a transformed document
Throws:
Thrown - if there is a problem with the transformation.
java.lang.Exception

transform

public static void transform(java.lang.String xsltFileName,
                             java.lang.String sourceFileName,
                             java.lang.String resultFileName)
                      throws java.lang.Exception
Transform a document.

Parameters:
xsltFileName - The name of the xsl file to be used.
sourceFileName - The name of the file to be read in and transformed.
resultFileName - The name of the file to be generated.
Throws:
Thrown - if there is a problem with the transformation.
java.lang.Exception