S-PLUS Connect/Java v1.0

com.insightful.splus.util
Class XMLTransformUtilities

java.lang.Object
  extended by com.insightful.splus.util.XMLTransformUtilities

public class XMLTransformUtilities
extends Object


Nested Class Summary
protected static class XMLTransformUtilities.SplusConverterOption
          Utility Class used by JFor transformation to ensure that the desired SAX implementation classes are used.
 
Field Summary
static int LOG_LEVEL_DEBUG
           
static int LOG_LEVEL_DISABLED
           
static int LOG_LEVEL_ERROR
           
static int LOG_LEVEL_FATAL
           
static int LOG_LEVEL_INFO
           
static int LOG_LEVEL_WARN
           
static int XSL_FO_PDF
           
static int XSL_FO_PS
           
static int XSL_FO_RTF
           
static int XSL_HTML
           
static int XSL_XML
           
 
Method Summary
static String convertStringToXML(String s)
          Create an XML-compatible string by removing any control characters from the input string.
static void createReport(String xml, String xsl, String report, int type)
          Create a formatted report in HTML, RTF, PDF, or Postscript based on content in an XML file and formatting information in an XSL file.
static void createReport(String xml, String xsl, String report, int type, int loggingLevel)
          Create a formatted report in HTML, RTF, PDF, or Postscript based on content in an XML file and formatting information in an XSL file.
static Transformer createTransformer(String xsl)
          Utilty method used to create a Transformer based on an XSL file.
static XMLReader createXmlReader()
          Utility method used to create an XMLReader from a SAX Parser.
static SAXSource createXmlSource(String xml)
          Utility method used to create a SAXSource from a given XML file path.
static DocumentBuilder getBuilder()
          Utility method used to create a singleton DocumentBuilder that will work properly when a computer is disconnected from the network.
static String getEncoding()
          Get the type of encoding used in subsequent XML document creation.
static EntityResolver getEntityResolver()
          Utility method used to create a singleton EntityResolver that will work properly when a computer is disconnected from the network.
static Node readFrdomFile(InputStream ins)
          IS THIS BEING USED ANYMORE?
static void serializeXML(Node node, OutputStream out)
          IS THIS BEING USED ANYMORE?
static void setEncoding(String encoding)
          Set the type of encoding used in subsequent XML document creation.
static void setParserProperties()
          Set System property hints for java xml implementation classes.
static void transformWithFOP(Source src, String xsl, OutputStream out)
          Utility method used to transform a given XML file, using a given XSL:FO transformation.
static void transformWithJFOR(Source xml, String xsl, Writer out, int log)
          Utility method used to transform a given XML file, using a given XSL:FO transformation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XSL_HTML

public static final int XSL_HTML
See Also:
Constant Field Values

XSL_XML

public static final int XSL_XML
See Also:
Constant Field Values

XSL_FO_PDF

public static final int XSL_FO_PDF
See Also:
Constant Field Values

XSL_FO_PS

public static final int XSL_FO_PS
See Also:
Constant Field Values

XSL_FO_RTF

public static final int XSL_FO_RTF
See Also:
Constant Field Values

LOG_LEVEL_DEBUG

public static final int LOG_LEVEL_DEBUG
See Also:
Constant Field Values

LOG_LEVEL_INFO

public static final int LOG_LEVEL_INFO
See Also:
Constant Field Values

LOG_LEVEL_WARN

public static final int LOG_LEVEL_WARN
See Also:
Constant Field Values

LOG_LEVEL_ERROR

public static final int LOG_LEVEL_ERROR
See Also:
Constant Field Values

LOG_LEVEL_FATAL

public static final int LOG_LEVEL_FATAL
See Also:
Constant Field Values

LOG_LEVEL_DISABLED

public static final int LOG_LEVEL_DISABLED
See Also:
Constant Field Values
Method Detail

setEncoding

public static void setEncoding(String encoding)
Set the type of encoding used in subsequent XML document creation.

Parameters:
encoding - Type of XML document encoding to be used when creating new documents.

getEncoding

public static String getEncoding()
Get the type of encoding used in subsequent XML document creation.


createReport

public static void createReport(String xml,
                                String xsl,
                                String report,
                                int type,
                                int loggingLevel)
                         throws Exception
Create a formatted report in HTML, RTF, PDF, or Postscript based on content in an XML file and formatting information in an XSL file. Can also be used to transform XML to another flavor of XML by using an XSLT file written to create the appropriate type of XML.

The HTML or XML transform uses an XSLT file. The PDF, PS, and RTF transforms use an XSL:FO transform.

The loggingLevel code indicates how much logging information to print to stdout. It is used by the PDF, PS, and RTF transforms.

Currently the HTML and XML transforms use classes in java's transform utility, the RTF transform uses classes in org.jfor, and the PDF and PS transforms use classes in org.apache.fop. The transform classes are standard JFC classes provided with JDK1.5, the org.jfor classes are available from www.jfor.org, and the org.apache.fop classes are available from www.apache.org. This implementation may change in the future as improved transformation tools become available.

Parameters:
xml - Name of XML file containing content of report
xsl - Name of XSLT or XSL:FO file containing formatting information
report - Name of output file
type - Type of transformation such as XSL_HTML
loggingLevel - Code indicating how much logging information to print this uses the org.apache.avalon.framework.logger.ConsoleLogger for PDF and PS, and org.jfor.jfor.converter.ConverterLogChannel for RTF. This may be deprecated at some point if the implementation changes to use tools that do not use these logging systems.
Throws:
Exception

createReport

public static void createReport(String xml,
                                String xsl,
                                String report,
                                int type)
                         throws Exception
Create a formatted report in HTML, RTF, PDF, or Postscript based on content in an XML file and formatting information in an XSL file. Can also be used to transform XML to another flavor of XML by using an XSLT file written to create the appropriate type of XML.

The HTML or XML transform uses an XSLT file. The PDF, PS, and RTF transforms use an XSL:FO transform.

The transformations will log warnings and errors to stdout.

Currently the HTML and XML transforms use classes in java's transform utility, the RTF transform uses classes in org.jfor, and the PDF and PS transforms use classes in org.apache.fop. The transform classes are standard JFC classes provided with JDK1.5, the org.jfor classes are available from www.jfor.org, and the org.apache.fop classes are available from www.apache.org. This implementation may change in the future as improved transformation tools become available.

Parameters:
xml - Name of XML file containing content of report
xsl - Name of XSLT or XSL:FO file containing formatting information
report - Name of output file
type - Type of transformation such as XSL_HTML
Throws:
Exception

setParserProperties

public static void setParserProperties()
Set System property hints for java xml implementation classes. If use.xalan is T, then the Xalan implementations will be used. Otherwise, the standard JDK 1.5 implementation will be used.


createXmlReader

public static XMLReader createXmlReader()
                                 throws Exception
Utility method used to create an XMLReader from a SAX Parser.

Throws:
Exception

createXmlSource

public static SAXSource createXmlSource(String xml)
                                 throws Exception
Utility method used to create a SAXSource from a given XML file path.

Parameters:
xml - string containing path to an XML file
Throws:
Exception

createTransformer

public static Transformer createTransformer(String xsl)
                                     throws Exception
Utilty method used to create a Transformer based on an XSL file. The function will first attempt to create a Transformer using the Template optimizations provided by the Transformer implementation. Failing that, a simple Transformer will be created. The optimized version will improve performance relative to memory and speed.

Parameters:
xsl - string containing path to an XSL file
Throws:
Exception

transformWithFOP

public static void transformWithFOP(Source src,
                                    String xsl,
                                    OutputStream out)
                             throws Exception
Utility method used to transform a given XML file, using a given XSL:FO transformation. A PDF file is output. This method makes use of the FOP package.

Parameters:
src - Source containing a given XML stream (to be transformed)
xsl - string containing path to a given XSL file (used to transform)
out - OutputStream pointing to a given output stream for PDF report
Throws:
Exception

transformWithJFOR

public static void transformWithJFOR(Source xml,
                                     String xsl,
                                     Writer out,
                                     int log)
                              throws Exception
Utility method used to transform a given XML file, using a given XSL:FO transformation. An RTF file is output. This method uses the JFor package.

Parameters:
xml - Source containing stream of a given XML file (to be transformed)
xsl - string containing path to a given XSL file (used to transform)
out - Writer containing output stream for generated report
log - Code indicating how much logging information to print this uses the org.apache.avalon.framework.logger.ConsoleLogger for PDF and PS, and org.jfor.jfor.converter.ConverterLogChannel for RTF. This may be deprecated at some point if the implementation changes to use tools that do not use these logging systems.
Throws:
Exception

convertStringToXML

public static String convertStringToXML(String s)
Create an XML-compatible string by removing any control characters from the input string.

Parameters:
s - String to be converted into XML

getEntityResolver

public static EntityResolver getEntityResolver()
Utility method used to create a singleton EntityResolver that will work properly when a computer is disconnected from the network.


getBuilder

public static DocumentBuilder getBuilder()
Utility method used to create a singleton DocumentBuilder that will work properly when a computer is disconnected from the network.


readFrdomFile

public static Node readFrdomFile(InputStream ins)
                          throws Exception
IS THIS BEING USED ANYMORE?

Throws:
Exception

serializeXML

public static void serializeXML(Node node,
                                OutputStream out)
IS THIS BEING USED ANYMORE?


S-PLUS Connect/Java v1.0

Copyright © 2000, 2002 Insightful Corporation
Warning: Classes not documented in the S-PLUS Programmer's Guide may change in future releases.