org.progeeks.util.xml
Class ObjectTransformingXmlReader

java.lang.Object
  extended by org.progeeks.util.xml.XmlReader
      extended by org.progeeks.util.xml.ObjectXmlReader
          extended by org.progeeks.util.xml.ObjectTransformingXmlReader

public class ObjectTransformingXmlReader
extends ObjectXmlReader

ObjectXmlReader subclass that loads objects from an XML source after applying a configurable XSL transformation.

Version:
$Revision: 1.6 $
Author:
Paul Wisneskey

Nested Class Summary
 
Nested classes/interfaces inherited from class org.progeeks.util.xml.ObjectXmlReader
ObjectXmlReader.ObjectTagReader
 
Nested classes/interfaces inherited from class org.progeeks.util.xml.XmlReader
XmlReader.XmlHandler
 
Field Summary
 
Fields inherited from class org.progeeks.util.xml.ObjectXmlReader
COLLECTION_VALUES_DIRECTIVE, CONFIG_DIRECTIVE, DIRECTIVE_PREFIX, EXISTING_VALUE_DIRECTIVE, FIELD_TYPE_DIRECTIVE, OID_DIRECTIVE, PRELOAD_DIRECTIVE, REFERENCE_DIRECTIVE
 
Constructor Summary
ObjectTransformingXmlReader()
          Creates an ObjectTransformingXmlReader that will read an object from an XML file based on the handler plug-ins that are later registered with it.
ObjectTransformingXmlReader(java.lang.String rootTag)
          Creates an ObjectTransformingXmlReader that will read a list of objects from an XML file based on the handler plug-ins that are later registered with it.
 
Method Summary
protected  void checkSourceXmlForStylesheet(java.io.Reader in)
          Attempts to determine a stylesheet for the supplied source document.
static void main(java.lang.String[] args)
          Main method used to dump a transformed XML to stdout to assist in debugging.
protected  void readXml(java.io.Reader in)
          Reads the source XML by passing it through the transformer and having the standard SAX handler process the transformed output.
 void setStyleSheet(java.io.InputStream stylesheet)
          Sets the stylesheet to the one loaded from the supplied input stream.
 void setStyleSheet(java.io.Reader stylesheet)
          Sets the stylesheet to the one loaded from the supplied reader.
protected  void setStyleSheet(javax.xml.transform.Source source)
          Sets the stylesheet by parsing the stylesheet definition from the supplied source.
 void setStyleSheet(java.lang.String stylesheet)
          Sets the stylesheet to one loaded from the supplied path.
 void setStyleSheetXml(java.lang.String stylesheetXml)
          Sets the stylesheet to the supplied XML string.
 
Methods inherited from class org.progeeks.util.xml.ObjectXmlReader
addObjectHandler, addObjectTagAlias, addStandardObjectHandlers, configureHandlers, getHandler, getObjectHandlers, getReferenceObject, ignoreAttribute, readObject, readObject, readObject, reset, setObjectHandlers
 
Methods inherited from class org.progeeks.util.xml.XmlReader
addTagText, createXmlException, createXmlException, endTag, getAttributesAsMap, getCurrentObject, getDocumentLocator, getIgnoreTagCase, getLocation, getPreviousObject, getRootObject, getStackSize, getTagReader, readXml, readXml, registerHandler, replaceCurrentObject, resolveEntity, setDefaultHandler, setIgnoreTagCase, startTag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectTransformingXmlReader

public ObjectTransformingXmlReader()
Creates an ObjectTransformingXmlReader that will read an object from an XML file based on the handler plug-ins that are later registered with it.


ObjectTransformingXmlReader

public ObjectTransformingXmlReader(java.lang.String rootTag)
Creates an ObjectTransformingXmlReader that will read a list of objects from an XML file based on the handler plug-ins that are later registered with it. The root-level tag must match the specified rootTag.

Method Detail

setStyleSheetXml

public void setStyleSheetXml(java.lang.String stylesheetXml)
Sets the stylesheet to the supplied XML string.

Parameters:
stylesheetXml - String containing the stylesheet XML.

setStyleSheet

public void setStyleSheet(java.lang.String stylesheet)
Sets the stylesheet to one loaded from the supplied path.

Parameters:
stylesheet - Path to a stylesheet definition to load.

setStyleSheet

public void setStyleSheet(java.io.InputStream stylesheet)
Sets the stylesheet to the one loaded from the supplied input stream.

Parameters:
stylesheet - Input stream containing a stylesheet definition.

setStyleSheet

public void setStyleSheet(java.io.Reader stylesheet)
Sets the stylesheet to the one loaded from the supplied reader.

Parameters:
stylesheet - Reader containing a stylesheet definition.

setStyleSheet

protected void setStyleSheet(javax.xml.transform.Source source)
Sets the stylesheet by parsing the stylesheet definition from the supplied source.

Parameters:
source - Source of the stylesheet to parse.

checkSourceXmlForStylesheet

protected void checkSourceXmlForStylesheet(java.io.Reader in)
Attempts to determine a stylesheet for the supplied source document. If a stylesheet is found, it will be loaded and the transformer created from it. If a stylesheet is not found, the transformer will be left unset. The supplied reader is not closed and should be reset to the start of its stream.

Parameters:
in - Source document to look for stylesheet configuration in.

readXml

protected void readXml(java.io.Reader in)
                throws java.io.IOException,
                       XmlException
Reads the source XML by passing it through the transformer and having the standard SAX handler process the transformed output.

Overrides:
readXml in class XmlReader
Parameters:
in - Source XML to read.
Throws:
java.io.IOException
XmlException

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Main method used to dump a transformed XML to stdout to assist in debugging.

Parameters:
args - Source XML and optional stylsheet.
Throws:
java.lang.Exception


Copyright © 2002-2003 Paul Speed. All Rights Reserved.