edu.ucsb.nceas.morpho.util
Class XMLTransformer

java.lang.Object
  |
  +--edu.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 CSS_PATH_XSLPROP
          used to hold path to css stylesheets
static java.lang.String DEFAULT_CSS_XSLPROP
          used to hold default css stylesheet name
static java.lang.String ENTITY_CSS_XSLPROP
          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 PACKAGE_ID_XSLPROP
          used to hold default css stylesheet name
static java.lang.String PACKAGE_INDEX_NAME_XSLPROP
          used to hold default css stylesheet 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 SUPPRESS_TRIPLES_OBJECTS_XSLPROP
          used to hold a list of all module ID(s) to be suppressed in DataPackage metaview.
static java.lang.String SUPPRESS_TRIPLES_SUBJECTS_XSLPROP
          used to hold a list of all module ID(s) to be suppressed in DataPackage metaview.
 
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!
 org.xml.sax.EntityResolver getEntityResolver()
          Gets the EntityResolver from the XML parser that will be used by this transformer.
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 setEntityResolver(org.xml.sax.EntityResolver resolver)
          Sets the EntityResolver for the XML parser that will be used by this 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)
          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)
          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_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:

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 in DataPackage metaview.

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 in DataPackage metaview.

PACKAGE_INDEX_NAME_XSLPROP

public static final java.lang.String PACKAGE_INDEX_NAME_XSLPROP
used to hold default css stylesheet name

PACKAGE_ID_XSLPROP

public static final java.lang.String PACKAGE_ID_XSLPROP
used to hold default css stylesheet name

DEFAULT_CSS_XSLPROP

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

ENTITY_CSS_XSLPROP

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

CSS_PATH_XSLPROP

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

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
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)
                         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 reading the Reader

transform

public java.io.Reader transform(org.w3c.dom.Document domDoc,
                                java.io.Reader xslStyleSheet)
                         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

setEntityResolver

public void setEntityResolver(org.xml.sax.EntityResolver resolver)
Sets the EntityResolver for the XML parser that will be used by this transformer. This is used to resolve PUBLIC and SYSTEM DOCIDs
Parameters:
resolver - the EntityResolver to be used

getEntityResolver

public org.xml.sax.EntityResolver getEntityResolver()
Gets the EntityResolver from the XML parser that will be used by this transformer. This is used to resolve PUBLIC and SYSTEM DOCIDs
Returns:
the EntityResolver to be used

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.