com.lotus.xsl
Class XMLParserLiaisonDefault

java.lang.Object
  |
  +--com.lotus.xsl.XMLParserLiaisonDefault
Direct Known Subclasses:
ProcessXSL, XML4JLiaison, XML4JLiaison4dom

public class XMLParserLiaisonDefault
extends java.lang.Object
implements XMLParserLiaison, Formatter

This class is the default XMLParserLiaison for the XSL Processor. It can be used alone, for programmatically built DOMs (I expect this use will be very rare), or it can be derived from, in order to make parser specific implementations.


Field Summary
 java.lang.String m_attrSpecialChars
          These are characters that will be escaped in the output.
 FormatterListener m_formatterListener
           
 XSLProcessor m_processor
          A pointer back to the owning XSL processor, mainly for use for warning and error handling.
 boolean m_use_validation
          If set to true, validation will be performed.
static java.lang.String S_XMLNAMESPACEURI
           
 
Constructor Summary
XMLParserLiaisonDefault()
          Construct an instance.
 
Method Summary
 com.lotus.xsl.Document createDocument()
          Create an empty DOM Document.
 com.lotus.xsl.Element getElementByID(java.lang.String id, com.lotus.xsl.Document doc)
          Given an ID, return the element.
 java.lang.String getExpandedAttributeName(com.lotus.xsl.Attr attr)
          Returns the attribute name with the namespace expanded.
 java.lang.String getExpandedElementName(com.lotus.xsl.Element elem)
          Returns the element name with the namespace expanded.
 FormatterListener getFormatterListener()
          Get an instance of the formatter listener that is associated with this formatter.
 int getIndent()
          Get the amount to indent when indent-result="yes".
 java.lang.String getLocalNameOfNode(com.lotus.xsl.Node n)
          Returns the local name of the given node.
 java.lang.String getNamespaceForPrefix(java.lang.String prefix, com.lotus.xsl.Element namespaceContext)
          Given a prefix and a namespace context, return the expanded namespace.
 java.lang.String getNamespaceOfNode(com.lotus.xsl.Node n)
          Returns the namespace of the given node.
 com.lotus.xsl.Node getParentOfNode(com.lotus.xsl.Node node)
          I have to write this silly, and expensive function, because the DOM WG decided that attributes don't have parents.
 java.lang.String getParserDescription()
          Return a string suitible for telling the user what parser is being used.
 boolean getShouldExpandEntityRefs()
          get whether or not to expand all entity references in the source and style trees.
 java.lang.String getSpecialCharacters()
          Get special characters for attributes that will be escaped.
 boolean getUseValidation()
          If set to true, validation will be performed.
 boolean isIgnorableWhitespace(com.lotus.xsl.Text node)
          Tell if the node is ignorable whitespace.
 com.lotus.xsl.Document parseXMLStream(java.io.Reader reader)
          Parse the text pointed at by the reader as XML, and return a DOM Document interface.
 com.lotus.xsl.Document parseXMLStream(java.io.Reader reader, java.lang.String filename)
          Parse the text pointed at by the reader as XML, and return a DOM Document interface.
 com.lotus.xsl.Document parseXMLStream(java.net.URL url)
          Parse the text pointed at by the URL, and return a DOM Document interface.
 void setFormatterListener(FormatterListener fl)
          Set an instance of the formatter listener that is associated with this formatter.
 void setFormatterListener(java.io.PrintWriter pw, java.lang.String resultns, boolean format)
          Set an instance of the formatter listener that is associated with this formatter.
 void setIndent(int i)
          Set the amount to indent when indent-result="yes".
 void setProcessorOwner(XSLProcessor processor)
          Set which processor this instance is associated with, mainly for use for error and warning handling.
 void SetShouldExpandEntityRefs(boolean b)
          Set whether or not to expand all entity references in the source and style trees.
 void setSpecialCharacters(java.lang.String str)
          Set special characters for attributes that will be escaped.
 void setUseValidation(boolean b)
          If set to true, validation will be performed.
 void toMarkup(com.lotus.xsl.Document doc, java.io.PrintWriter pw, java.lang.String resultns, boolean format)
          Print a DOM tree.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_processor

public XSLProcessor m_processor
A pointer back to the owning XSL processor, mainly for use for warning and error handling.

m_use_validation

public boolean m_use_validation
If set to true, validation will be performed. Validation is off by default.

m_attrSpecialChars

public java.lang.String m_attrSpecialChars
These are characters that will be escaped in the output.

S_XMLNAMESPACEURI

public static final java.lang.String S_XMLNAMESPACEURI

m_formatterListener

public FormatterListener m_formatterListener
Constructor Detail

XMLParserLiaisonDefault

public XMLParserLiaisonDefault()
Construct an instance.
Method Detail

getParserDescription

public java.lang.String getParserDescription()
Return a string suitible for telling the user what parser is being used.
Specified by:
getParserDescription in interface XMLParserLiaison

getIndent

public int getIndent()
Get the amount to indent when indent-result="yes".
Specified by:
getIndent in interface XMLParserLiaison

setIndent

public void setIndent(int i)
Set the amount to indent when indent-result="yes".
Specified by:
setIndent in interface XMLParserLiaison

getShouldExpandEntityRefs

public boolean getShouldExpandEntityRefs()
get whether or not to expand all entity references in the source and style trees.
Specified by:
getShouldExpandEntityRefs in interface XMLParserLiaison

SetShouldExpandEntityRefs

public void SetShouldExpandEntityRefs(boolean b)
Set whether or not to expand all entity references in the source and style trees.
Specified by:
SetShouldExpandEntityRefs in interface XMLParserLiaison

getUseValidation

public boolean getUseValidation()
If set to true, validation will be performed. Validation is off by default.
Specified by:
getUseValidation in interface XMLParserLiaison

setUseValidation

public void setUseValidation(boolean b)
If set to true, validation will be performed. Validation is off by default.
Specified by:
setUseValidation in interface XMLParserLiaison

setSpecialCharacters

public void setSpecialCharacters(java.lang.String str)
Set special characters for attributes that will be escaped.
Specified by:
setSpecialCharacters in interface XMLParserLiaison

getSpecialCharacters

public java.lang.String getSpecialCharacters()
Get special characters for attributes that will be escaped.
Specified by:
getSpecialCharacters in interface XMLParserLiaison

setProcessorOwner

public void setProcessorOwner(XSLProcessor processor)
Set which processor this instance is associated with, mainly for use for error and warning handling. This must be set, but should normally by set by the XSLProcessor class.
Specified by:
setProcessorOwner in interface XMLParserLiaison

parseXMLStream

public com.lotus.xsl.Document parseXMLStream(java.io.Reader reader)
                                      throws java.io.IOException,
                                             XSLProcessorException
Parse the text pointed at by the reader as XML, and return a DOM Document interface. May return null if not supported.
Specified by:
parseXMLStream in interface XMLParserLiaison
Parameters:
reader - A stream that should hold valid XML.
Throws:
java.io.IOException - thrown if unable to open the XML stream.
XSLProcessorException - thrown for all other error conditions.

parseXMLStream

public com.lotus.xsl.Document parseXMLStream(java.io.Reader reader,
                                             java.lang.String filename)
                                      throws java.io.IOException,
                                             XSLProcessorException
Parse the text pointed at by the reader as XML, and return a DOM Document interface. Implementation of XMLParserLiaison interface method. Default handling: Not supported - need parser-specific implementation.
Specified by:
parseXMLStream in interface XMLParserLiaison
Throws:
java.io.IOException - thrown if unable to open the XML stream.
XSLProcessorException - thrown for all other error conditions.

parseXMLStream

public com.lotus.xsl.Document parseXMLStream(java.net.URL url)
                                      throws java.io.IOException,
                                             XSLProcessorException
Parse the text pointed at by the URL, and return a DOM Document interface. Implementation of XMLParserLiaison interface method. Default handling: Not supported - need parser-specific implementation.
Specified by:
parseXMLStream in interface XMLParserLiaison
Throws:
java.io.IOException - thrown if unable to open the XML stream.
XSLProcessorException - thrown for all other error conditions.

createDocument

public com.lotus.xsl.Document createDocument()
Create an empty DOM Document. Mainly used for creating an output document. Implementation of XMLParserLiaison interface method. Default handling: Not supported - need parser-specific implementation.
Specified by:
createDocument in interface XMLParserLiaison

getNamespaceForPrefix

public java.lang.String getNamespaceForPrefix(java.lang.String prefix,
                                              com.lotus.xsl.Element namespaceContext)
Given a prefix and a namespace context, return the expanded namespace. Default handling:
Specified by:
getNamespaceForPrefix in interface XMLParserLiaison

getNamespaceOfNode

public java.lang.String getNamespaceOfNode(com.lotus.xsl.Node n)
Returns the namespace of the given node.
Specified by:
getNamespaceOfNode in interface XMLParserLiaison

getLocalNameOfNode

public java.lang.String getLocalNameOfNode(com.lotus.xsl.Node n)
Returns the local name of the given node.
Specified by:
getLocalNameOfNode in interface XMLParserLiaison

getExpandedElementName

public java.lang.String getExpandedElementName(com.lotus.xsl.Element elem)
Returns the element name with the namespace expanded.
Specified by:
getExpandedElementName in interface XMLParserLiaison

getExpandedAttributeName

public java.lang.String getExpandedAttributeName(com.lotus.xsl.Attr attr)
Returns the attribute name with the namespace expanded.
Specified by:
getExpandedAttributeName in interface XMLParserLiaison

isIgnorableWhitespace

public boolean isIgnorableWhitespace(com.lotus.xsl.Text node)
Tell if the node is ignorable whitespace.
Specified by:
isIgnorableWhitespace in interface XMLParserLiaison

getParentOfNode

public com.lotus.xsl.Node getParentOfNode(com.lotus.xsl.Node node)
                                   throws java.lang.RuntimeException
I have to write this silly, and expensive function, because the DOM WG decided that attributes don't have parents. If LotusXSL is used with a DOM implementation that reuses attribute nodes, this will not work correctly.
Specified by:
getParentOfNode in interface XMLParserLiaison

getElementByID

public com.lotus.xsl.Element getElementByID(java.lang.String id,
                                            com.lotus.xsl.Document doc)
Given an ID, return the element.
Specified by:
getElementByID in interface XMLParserLiaison

setFormatterListener

public void setFormatterListener(java.io.PrintWriter pw,
                                 java.lang.String resultns,
                                 boolean format)
Set an instance of the formatter listener that is associated with this formatter.
Specified by:
setFormatterListener in interface Formatter

setFormatterListener

public void setFormatterListener(FormatterListener fl)
Set an instance of the formatter listener that is associated with this formatter.
Specified by:
setFormatterListener in interface Formatter

getFormatterListener

public FormatterListener getFormatterListener()
Get an instance of the formatter listener that is associated with this formatter. For now this just returns null.
Specified by:
getFormatterListener in interface Formatter

toMarkup

public void toMarkup(com.lotus.xsl.Document doc,
                     java.io.PrintWriter pw,
                     java.lang.String resultns,
                     boolean format)
              throws java.lang.Exception
Print a DOM tree.
Specified by:
toMarkup in interface Formatter
Parameters:
doc - The result tree.
pw - The PrintWriter to print the contents to.
resultns - the value of the resultns attribute.
format - Tells if it should be pretty-printed.