edu.ucsb.nceas.morpho.util
Class XMLTransformer

java.lang.Object
  extended byedu.ucsb.nceas.morpho.util.XMLTransformer

public class XMLTransformer
extends java.lang.Object

XMLTransformer to style XML documents using XSLT


Field Summary
static java.lang.String ATTRIB_NAME_FOR_SCHEMA_LOCATION
          used by the transform() method to get the schemaLocation (if one has been defined) from the Document root node
static java.lang.String CSS_PATH_XSLPROP
          xsl property used to hold path to css stylesheets
static java.lang.String DEFAULT_CSS_XSLPROP
          xsl property used to hold default css stylesheet name
static java.lang.String ENTITY_CSS_XSLPROP
          xsl property used to hold entity/attribute css stylesheet name
static java.lang.String HREF_PATH_EXTENSION_XSLPROP
          used to hold path extension for href links in triples.
static java.lang.String ID_TO_GET_GENERIC_STYLESHEET
          used by the transform() method to get the schemaLocation (if one has been defined) from the Document root node
static java.lang.String NAMESPACE_FOR_SCHEMA_LOCATION
          used by the transform() method to get the schemaLocation (if one has been defined) from the Document root node
static java.lang.String PACKAGE_ID_XSLPROP
          xsl property used to hold package id
static java.lang.String PACKAGE_INDEX_NAME_XSLPROP
          xsl property used to hold package index name
static java.lang.String SELECTED_ATTRIBS_XSLPROP
          SELECTED_ATTRIBS_XSLPROP used to identify selected attribute(s) when clicking on col headers (NOTE - identified by column index (0..n) - not by attribute ID:
static java.lang.String SELECTED_DISPLAY_XSLPROP
          SELECTED_DISPLAY_XSLPROP used to identify the display type
static java.lang.String SELECTED_ENTITY_XSLPROP
          SELECTED_ATTRIBS_XSLPROP used to identify selected entity when clicking on col headers
static java.lang.String SUPPRESS_TRIPLES_DELIMETER
          used to delimit the list of all module ID(s) to be suppressed in DataPackage metaview.
static java.lang.String SUPPRESS_TRIPLES_OBJECTS_XSLPROP
          used to hold a list of all module ID(s) to be suppressed as triples OBJECTS in DataPackage metaview.
static java.lang.String SUPPRESS_TRIPLES_SUBJECTS_XSLPROP
          used to hold a list of all module ID(s) to be suppressed as triples SUBJECTS in DataPackage metaview.
static java.lang.String XSLVALU_DISPLAY_ATTRB
          XSLVALU_DISPLAY_ATTRB is the value to display attributes
static java.lang.String XSLVALU_DISPLAY_DATASET
          XSLVALU_DISPLAY_DATASET is the value to display dataset
static java.lang.String XSLVALU_DISPLAY_ENTITY
          XSLVALU_DISPLAY_ENTITY is the value to display entity
static java.lang.String XSLVALU_DISPLAY_PRNT
          XSLVALU_DISPLAY_PRNT is the value to display print output
 
Method Summary
 void addTransformerProperty(java.lang.String key, java.lang.String value)
          adds a name/value pair to the Properties object containing the properties to be set for the transformer
 java.util.Properties getCurrentTransformerProperties()
          Returns all name/value pairs describing the properties to be set for the transformer, in the form of a Properties object *NOTE* this method returns a clone of the Properties, not a reference to the Properties object itself!
static XMLTransformer getInstance()
          Used to get a shared instance of the XMLTransformer
 java.lang.String getTransformerProperty(java.lang.String key)
          Gets the String value of the Property corresponding to the key passed in
 java.util.Enumeration getTransformerPropertyNames()
          Gets an Enumeration containing the names (keys of all the properties to be set for the transformer
 void removeAllTransformerProperties()
          removes all name/value pairs from the Properties object containing the properties to be set for the transformer
 void removeTransformerProperty(java.lang.String key)
          removes a name/value pair from the Properties object containing the properties to be set for the transformer
 void setTransformerProperties(java.util.Properties newProps)
          The Properties object passed to this method will be used to set all the name/value pairs describing the properties to be set for the transformer.
 java.io.Reader transform(org.w3c.dom.Document domDoc)
          transforms the passed XML document, using a "generic" stylesheet, whose name is obtained from the config.xml file
 java.io.Reader transform(org.w3c.dom.Document domDoc, java.io.Reader xslStyleSheet, java.lang.String xsltLocation)
          Uses the stylesheet provided, to apply XSLT to the XML DOM Document provided
 java.io.Reader transform(java.io.Reader xmlDocReader)
          transforms the passed XML document, using a "generic" stylesheet, whose name is obtained from the config.xml file
 java.io.Reader transform(java.io.Reader xmlDocReader, java.io.Reader xslStyleSheet, java.lang.String xsltLocation)
          Uses the stylesheet provided, to apply XSLT to the XML document provided
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECTED_DISPLAY_XSLPROP

public static final java.lang.String SELECTED_DISPLAY_XSLPROP
SELECTED_DISPLAY_XSLPROP used to identify the display type

See Also:
Constant Field Values

XSLVALU_DISPLAY_DATASET

public static final java.lang.String XSLVALU_DISPLAY_DATASET
XSLVALU_DISPLAY_DATASET is the value to display dataset

See Also:
Constant Field Values

XSLVALU_DISPLAY_ENTITY

public static final java.lang.String XSLVALU_DISPLAY_ENTITY
XSLVALU_DISPLAY_ENTITY is the value to display entity

See Also:
Constant Field Values

XSLVALU_DISPLAY_ATTRB

public static final java.lang.String XSLVALU_DISPLAY_ATTRB
XSLVALU_DISPLAY_ATTRB is the value to display attributes

See Also:
Constant Field Values

XSLVALU_DISPLAY_PRNT

public static final java.lang.String XSLVALU_DISPLAY_PRNT
XSLVALU_DISPLAY_PRNT is the value to display print output

See Also:
Constant Field Values

SELECTED_ENTITY_XSLPROP

public static final java.lang.String SELECTED_ENTITY_XSLPROP
SELECTED_ATTRIBS_XSLPROP used to identify selected entity when clicking on col headers

See Also:
Constant Field Values

SELECTED_ATTRIBS_XSLPROP

public static final java.lang.String SELECTED_ATTRIBS_XSLPROP
SELECTED_ATTRIBS_XSLPROP used to identify selected attribute(s) when clicking on col headers (NOTE - identified by column index (0..n) - not by attribute ID:

See Also:
Constant Field Values

SUPPRESS_TRIPLES_SUBJECTS_XSLPROP

public static final java.lang.String SUPPRESS_TRIPLES_SUBJECTS_XSLPROP
used to hold a list of all module ID(s) to be suppressed as triples SUBJECTS in DataPackage metaview.

See Also:
Constant Field Values

SUPPRESS_TRIPLES_OBJECTS_XSLPROP

public static final java.lang.String SUPPRESS_TRIPLES_OBJECTS_XSLPROP
used to hold a list of all module ID(s) to be suppressed as triples OBJECTS in DataPackage metaview.

See Also:
Constant Field Values

SUPPRESS_TRIPLES_DELIMETER

public static final java.lang.String SUPPRESS_TRIPLES_DELIMETER
used to delimit the list of all module ID(s) to be suppressed in DataPackage metaview.

See Also:

PACKAGE_INDEX_NAME_XSLPROP

public static final java.lang.String PACKAGE_INDEX_NAME_XSLPROP
xsl property used to hold package index name

See Also:
Constant Field Values

PACKAGE_ID_XSLPROP

public static final java.lang.String PACKAGE_ID_XSLPROP
xsl property used to hold package id

See Also:
Constant Field Values

DEFAULT_CSS_XSLPROP

public static final java.lang.String DEFAULT_CSS_XSLPROP
xsl property used to hold default css stylesheet name

See Also:
Constant Field Values

ENTITY_CSS_XSLPROP

public static final java.lang.String ENTITY_CSS_XSLPROP
xsl property used to hold entity/attribute css stylesheet name

See Also:
Constant Field Values

CSS_PATH_XSLPROP

public static final java.lang.String CSS_PATH_XSLPROP
xsl property used to hold path to css stylesheets

See Also:
Constant Field Values

HREF_PATH_EXTENSION_XSLPROP

public static final java.lang.String HREF_PATH_EXTENSION_XSLPROP
used to hold path extension for href links in triples. Value SHOULD INCLUDE "." - i.e. typically set to ".html" for export files, and set to empty string for links inside Morpho UI

See Also:
Constant Field Values

NAMESPACE_FOR_SCHEMA_LOCATION

public static final java.lang.String NAMESPACE_FOR_SCHEMA_LOCATION
used by the transform() method to get the schemaLocation (if one has been defined) from the Document root node

See Also:
Constant Field Values

ATTRIB_NAME_FOR_SCHEMA_LOCATION

public static final java.lang.String ATTRIB_NAME_FOR_SCHEMA_LOCATION
used by the transform() method to get the schemaLocation (if one has been defined) from the Document root node

See Also:
Constant Field Values

ID_TO_GET_GENERIC_STYLESHEET

public static final java.lang.String ID_TO_GET_GENERIC_STYLESHEET
used by the transform() method to get the schemaLocation (if one has been defined) from the Document root node

See Also:
Constant Field Values
Method Detail

getInstance

public static XMLTransformer getInstance()
Used to get a shared instance of the XMLTransformer

Returns:
a shared instance of the XMLTransformer

transform

public java.io.Reader transform(java.io.Reader xmlDocReader)
                         throws java.io.IOException
transforms the passed XML document, using a "generic" stylesheet, whose name is obtained from the config.xml file

Parameters:
xmlDocReader - A java.io.Reader to allow reading of the XML document to be styled.
Returns:
A java.io.Reader to allow reading of the (character-based) results of styling the XML document
Throws:
java.io.IOException - if there are problems reading the Reader

transform

public java.io.Reader transform(java.io.Reader xmlDocReader,
                                java.io.Reader xslStyleSheet,
                                java.lang.String xsltLocation)
                         throws java.io.IOException
Uses the stylesheet provided, to apply XSLT to the XML document provided

Parameters:
xmlDocReader - A java.io.Reader to allow reading of the XML document to be styled.
xslStyleSheet - A java.io.Reader to allow reading of the XSL stylesheet to be used
Returns:
A java.io.Reader to allow reading of the results of styling the XML document
Throws:
java.io.IOException - if there are problems reading either of the Readers

transform

public java.io.Reader transform(org.w3c.dom.Document domDoc)
                         throws java.io.IOException
transforms the passed XML document, using a "generic" stylesheet, whose name is obtained from the config.xml file

Parameters:
domDoc - A javax.xml.parsers.Document containing the XML document to be styled.
Returns:
A java.io.Reader to allow reading of the (character-based) results of styling the XML document
Throws:
java.io.IOException - if there are problems transforming the Document

transform

public java.io.Reader transform(org.w3c.dom.Document domDoc,
                                java.io.Reader xslStyleSheet,
                                java.lang.String xsltLocation)
                         throws java.io.IOException
Uses the stylesheet provided, to apply XSLT to the XML DOM Document provided

Parameters:
domDoc - A javax.xml.parsers.Document containing the XML document to be styled.
xslStyleSheet - A java.io.Reader to allow reading of the XSL stylesheet to be used
Returns:
A java.io.Reader to allow reading of the results of styling the XML document
Throws:
java.io.IOException - if there are problems reading either of the Readers

addTransformerProperty

public void addTransformerProperty(java.lang.String key,
                                   java.lang.String value)
adds a name/value pair to the Properties object containing the properties to be set for the transformer

Parameters:
key - the key to be used
value - the corresponding value to be set

removeTransformerProperty

public void removeTransformerProperty(java.lang.String key)
removes a name/value pair from the Properties object containing the properties to be set for the transformer

Parameters:
key - the key of the entry to be removed

removeAllTransformerProperties

public void removeAllTransformerProperties()
removes all name/value pairs from the Properties object containing the properties to be set for the transformer


setTransformerProperties

public void setTransformerProperties(java.util.Properties newProps)
The Properties object passed to this method will be used to set all the name/value pairs describing the properties to be set for the transformer. The new settings will supersede any previous settings

Parameters:
newProps - the Properties containing all the object name/value pairs describing the properties to be set for the transformer

getCurrentTransformerProperties

public java.util.Properties getCurrentTransformerProperties()
Returns all name/value pairs describing the properties to be set for the transformer, in the form of a Properties object *NOTE* this method returns a clone of the Properties, not a reference to the Properties object itself!

Returns:
A clone of the Properties containing object name/value pairs describing the properties to be set for the transformer

getTransformerPropertyNames

public java.util.Enumeration getTransformerPropertyNames()
Gets an Enumeration containing the names (keys of all the properties to be set for the transformer

Returns:
an Enumeration containing the names

getTransformerProperty

public java.lang.String getTransformerProperty(java.lang.String key)
Gets the String value of the Property corresponding to the key passed in

Returns:
the String value of the Property corresponding to the key passed in


Copyright © 2000 National Center for Ecological Analysis and Synthesis. All Rights Reserved.