BEA Systems, Inc.

WebLogic Server 6.1 API Reference

weblogic.apache.xalan.stree
Class SourceTreeHandler

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--weblogic.apache.xalan.stree.SourceTreeHandler

public class SourceTreeHandler
extends org.xml.sax.helpers.DefaultHandler
implements javax.xml.transform.sax.TransformerHandler, org.xml.sax.ext.DeclHandler, org.xml.sax.DTDHandler

This class handles SAX2 parse events to create a source tree for transformation.

This class is based on an implementation from the Apache XML Project. In future releases the XML parser, XSLT processor, and associated classes will likely be updated to be based on a later version of the Apache implementations. Since Apache does not guarantee backwards compatibility between versions of their software, we cannot guarantee backwards compatibility of any of the classes contained in the weblogic.apache package or sub-packages.


Constructor Summary
SourceTreeHandler()
          Create a SourceTreeHandler.
SourceTreeHandler(TransformerImpl transformer)
          Create a SourceTreeHandler that will start a transformation as soon as a startDocument occurs.
SourceTreeHandler(TransformerImpl transformer, boolean doFragment)
          Create a SourceTreeHandler that will start a transformation as soon as a startDocument occurs.
 
Method Summary
 void attributeDecl(java.lang.String eName, java.lang.String aName, java.lang.String type, java.lang.String valueDefault, java.lang.String value)
          Report an attribute type declaration.
 void characters(char[] ch, int start, int length)
          Implement the characters event.
 void charactersRaw(char[] ch, int start, int length)
          Implement the characters event.
 void comment(char[] ch, int start, int length)
          Report an XML comment anywhere in the document.
 void elementDecl(java.lang.String name, java.lang.String model)
          Report an element type declaration.
 void endCDATA()
          Report the end of a CDATA section.
 void endDocument()
          Implement the endDocument event.
 void endDTD()
          Report the end of DTD declarations.
 void endElement(java.lang.String ns, java.lang.String localName, java.lang.String name)
          Implement the endElement event.
 void endEntity(java.lang.String name)
          Report the end of an entity.
 void endPrefixMapping(java.lang.String prefix)
          End the scope of a prefix-URI mapping.
 void externalEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          Report a parsed external entity declaration.
 javax.xml.transform.Source getInputSource()
          Get Source Document.
 org.w3c.dom.Node getRoot()
          Get the root document of tree that is being or will be created.
 java.lang.String getSystemId()
          Get the base ID (URI or system ID) from where relative URLs will be resolved.
 javax.xml.transform.Transformer getTransformer()
          Get the Transformer associated with this handler, which is needed in order to set parameters and output properties.
 boolean getUseMultiThreading()
          Tell whether or not the tree being built should handle transformation while the parse is still going on.
 void ignorableWhitespace(char[] ch, int start, int length)
          Implement the ignorableWhitespace event.
 void internalEntityDecl(java.lang.String name, java.lang.String value)
          Report an internal entity declaration.
 void notationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          Receive notification of a notation declaration event.
 void processingInstruction(java.lang.String target, java.lang.String data)
          Implement the processingInstruction event.
 void setDocumentLocator(org.xml.sax.Locator locator)
          Implement the setDocumentLocator event.
 void setExceptionThrown(java.lang.Exception e)
          If an exception was thrown, keep track of it
 void setInputSource(javax.xml.transform.Source source)
          Set the Source document
 void setResult(javax.xml.transform.Result result)
          Method setResult allows the user of the TransformerHandler to set the result of the transform.
 void setRoot(DocImpl root)
          Set the root document of tree will be created.
 void setShouldTransformAtEnd(boolean b)
           
 void setSystemId(java.lang.String baseID)
          Set the base ID (URL or system ID) from where relative URLs will be resolved.
 void setUseMultiThreading(boolean b)
          Set whether or not the tree being built should handle transformation while the parse is still going on.
 void skippedEntity(java.lang.String name)
          Receive notification of a skipped entity.
 void startCDATA()
          Report the start of a CDATA section.
 void startDocument()
          Implement the startDocument event.
 void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          Report the start of DTD declarations, if any.
 void startElement(java.lang.String ns, java.lang.String localName, java.lang.String name, org.xml.sax.Attributes atts)
          Implement the startElement event.
 void startEntity(java.lang.String name)
          Report the beginning of an entity.
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          Begin the scope of a prefix-URI Namespace mapping.
 void unparsedEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notationName)
          Receive notification of an unparsed entity declaration event.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
error, fatalError, resolveEntity, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SourceTreeHandler

public SourceTreeHandler(TransformerImpl transformer)
Create a SourceTreeHandler that will start a transformation as soon as a startDocument occurs.

Parameters:
transformer - The transformer this will use to transform a source tree into a result tree.

SourceTreeHandler

public SourceTreeHandler(TransformerImpl transformer,
                         boolean doFragment)
Create a SourceTreeHandler that will start a transformation as soon as a startDocument occurs.

Parameters:
transformer - The transformer this will use to transform a source tree into a result tree.

SourceTreeHandler

public SourceTreeHandler()
Create a SourceTreeHandler.
Method Detail

setShouldTransformAtEnd

public void setShouldTransformAtEnd(boolean b)


getRoot

public org.w3c.dom.Node getRoot()
Get the root document of tree that is being or will be created.

Returns:
Root document

setRoot

public void setRoot(DocImpl root)
Set the root document of tree will be created.

Parameters:
root - root document of tree that will be created

setExceptionThrown

public void setExceptionThrown(java.lang.Exception e)
If an exception was thrown, keep track of it

Parameters:
e - Exception that was thrown

setInputSource

public void setInputSource(javax.xml.transform.Source source)
Set the Source document

Parameters:
source - source document

getInputSource

public javax.xml.transform.Source getInputSource()
Get Source Document.

Returns:
source document

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Implement the setDocumentLocator event.

Parameters:
locator - Document locator
Overrides:
setDocumentLocator in class org.xml.sax.helpers.DefaultHandler

setUseMultiThreading

public void setUseMultiThreading(boolean b)
Set whether or not the tree being built should handle transformation while the parse is still going on.

Parameters:
b - Flag to indicate whether to use multiple threads

getUseMultiThreading

public boolean getUseMultiThreading()
Tell whether or not the tree being built should handle transformation while the parse is still going on.

Returns:
Flag to indicate whether to use multiple threads

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Implement the startDocument event.

Throws:
org.xml.sax.SAXException -  
Overrides:
startDocument in class org.xml.sax.helpers.DefaultHandler

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Implement the endDocument event.

Throws:
org.xml.sax.SAXException -  
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler

startElement

public void startElement(java.lang.String ns,
                         java.lang.String localName,
                         java.lang.String name,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Implement the startElement event.

Parameters:
ns - Namespace of the element
localName - Local part of the qualified name of the element
name - Name of the element
atts - List of attributes associated with the element
Throws:
org.xml.sax.SAXException -  
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler

endElement

public void endElement(java.lang.String ns,
                       java.lang.String localName,
                       java.lang.String name)
                throws org.xml.sax.SAXException
Implement the endElement event.

Parameters:
ns - Namespace of the element
localName - Local part of the qualified name of the element
name - Name of the element
Throws:
org.xml.sax.SAXException -  
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler

startCDATA

public void startCDATA()
                throws org.xml.sax.SAXException
Report the start of a CDATA section.

The contents of the CDATA section will be reported through the regular characters event.

Throws:
org.xml.sax.SAXException - The application may raise an exception.
See Also:
endCDATA()

endCDATA

public void endCDATA()
              throws org.xml.sax.SAXException
Report the end of a CDATA section.

Throws:
org.xml.sax.SAXException - The application may raise an exception.
See Also:
startCDATA()

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Implement the characters event.

Parameters:
ch - Character array from the characters event
start - Start index of characters to process in the array
length - Number of characters to process in the array
Throws:
org.xml.sax.SAXException -  
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler

charactersRaw

public void charactersRaw(char[] ch,
                          int start,
                          int length)
                   throws org.xml.sax.SAXException
Implement the characters event.

Parameters:
ch - Character array from the characters event
start - Start index of characters to process in the array
length - Number of characters to process in the array
Throws:
org.xml.sax.SAXException -  

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
Implement the ignorableWhitespace event.

Parameters:
ch - Character array from the characters event
start - Start index of characters to process in the array
length - Number of characters to process in the array
Throws:
org.xml.sax.SAXException -  
Overrides:
ignorableWhitespace in class org.xml.sax.helpers.DefaultHandler

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Implement the processingInstruction event.

Parameters:
target - Target of PI node
data - Content of PI node
Throws:
org.xml.sax.SAXException -  
Overrides:
processingInstruction in class org.xml.sax.helpers.DefaultHandler

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws org.xml.sax.SAXException
Report an XML comment anywhere in the document.

This callback will be used for comments inside or outside the document element, including comments in the external DTD subset (if read).

Parameters:
ch - An array holding the characters in the comment.
start - The starting position in the array.
length - The number of characters to use from the array.
Throws:
org.xml.sax.SAXException - The application may raise an exception.

startEntity

public void startEntity(java.lang.String name)
                 throws org.xml.sax.SAXException
Report the beginning of an entity.

The start and end of the document entity are not reported. The start and end of the external DTD subset are reported using the pseudo-name "[dtd]". All other events must be properly nested within start/end entity events.

Note that skipped entities will be reported through the skippedEntity event, which is part of the ContentHandler interface.

Parameters:
name - The name of the entity. If it is a parameter entity, the name will begin with '%'.
Throws:
org.xml.sax.SAXException - The application may raise an exception.
See Also:
endEntity(java.lang.String), DeclHandler.internalEntityDecl(java.lang.String, java.lang.String), DeclHandler.externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)

endEntity

public void endEntity(java.lang.String name)
               throws org.xml.sax.SAXException
Report the end of an entity.

Parameters:
name - The name of the entity that is ending.
Throws:
org.xml.sax.SAXException - The application may raise an exception.
See Also:
startEntity(java.lang.String)

startDTD

public void startDTD(java.lang.String name,
                     java.lang.String publicId,
                     java.lang.String systemId)
              throws org.xml.sax.SAXException
Report the start of DTD declarations, if any.

Any declarations are assumed to be in the internal subset unless otherwise indicated by a startEntity event.

Parameters:
name - The document type name.
publicId - The declared public identifier for the external DTD subset, or null if none was declared.
systemId - The declared system identifier for the external DTD subset, or null if none was declared.
Throws:
org.xml.sax.SAXException - The application may raise an exception.
See Also:
endDTD(), startEntity(java.lang.String)

endDTD

public void endDTD()
            throws org.xml.sax.SAXException
Report the end of DTD declarations.

Throws:
org.xml.sax.SAXException - The application may raise an exception.
See Also:
startDTD(java.lang.String, java.lang.String, java.lang.String)

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
Begin the scope of a prefix-URI Namespace mapping.

The information from this event is not necessary for normal Namespace processing: the SAX XML reader will automatically replace prefixes for element and attribute names when the http://xml.org/sax/features/namespaces feature is true (the default).

There are cases, however, when applications need to use prefixes in character data or in attribute values, where they cannot safely be expanded automatically; the start/endPrefixMapping event supplies the information to the application to expand prefixes in those contexts itself, if necessary.

Note that start/endPrefixMapping events are not guaranteed to be properly nested relative to each-other: all startPrefixMapping events will occur before the corresponding startElement event, and all endPrefixMapping events will occur after the corresponding endElement event, but their order is not guaranteed.

Parameters:
prefix - The Namespace prefix being declared.
uri - The Namespace URI the prefix is mapped to.
Throws:
org.xml.sax.SAXException -  
Overrides:
startPrefixMapping in class org.xml.sax.helpers.DefaultHandler
See Also:
endPrefixMapping(java.lang.String), startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
                      throws org.xml.sax.SAXException
End the scope of a prefix-URI mapping.

See startPrefixMapping for details. This event will always occur after the corresponding endElement event, but the order of endPrefixMapping events is not otherwise guaranteed.

Parameters:
prefix - The prefix that was being mapping.
Throws:
org.xml.sax.SAXException -  
Overrides:
endPrefixMapping in class org.xml.sax.helpers.DefaultHandler
See Also:
startPrefixMapping(java.lang.String, java.lang.String), endElement(java.lang.String, java.lang.String, java.lang.String)

skippedEntity

public void skippedEntity(java.lang.String name)
                   throws org.xml.sax.SAXException
Receive notification of a skipped entity.

The Parser will invoke this method once for each entity skipped. Non-validating processors may skip entities if they have not seen the declarations (because, for example, the entity was declared in an external DTD subset). All processors may skip external entities, depending on the values of the http://xml.org/sax/features/external-general-entities and the http://xml.org/sax/features/external-parameter-entities properties.

Parameters:
name - The name of the skipped entity. If it is a parameter entity, the name will begin with '%'.
Throws:
org.xml.sax.SAXException -  
Overrides:
skippedEntity in class org.xml.sax.helpers.DefaultHandler

setResult

public void setResult(javax.xml.transform.Result result)
               throws java.lang.IllegalArgumentException
Method setResult allows the user of the TransformerHandler to set the result of the transform.
Specified by:
setResult in interface javax.xml.transform.sax.TransformerHandler

Parameters:
result - A Result instance, should not be null.
Throws:
java.lang.IllegalArgumentException - if result is invalid for some reason.

setSystemId

public void setSystemId(java.lang.String baseID)
Set the base ID (URL or system ID) from where relative URLs will be resolved.
Specified by:
setSystemId in interface javax.xml.transform.sax.TransformerHandler

Parameters:
baseID - Base URL for the source tree.

getSystemId

public java.lang.String getSystemId()
Get the base ID (URI or system ID) from where relative URLs will be resolved.
Specified by:
getSystemId in interface javax.xml.transform.sax.TransformerHandler

Returns:
The systemID that was set with setSystemId(java.lang.String).

getTransformer

public javax.xml.transform.Transformer getTransformer()
Get the Transformer associated with this handler, which is needed in order to set parameters and output properties.
Specified by:
getTransformer in interface javax.xml.transform.sax.TransformerHandler


elementDecl

public void elementDecl(java.lang.String name,
                        java.lang.String model)
                 throws org.xml.sax.SAXException
Report an element type declaration.

The content model will consist of the string "EMPTY", the string "ANY", or a parenthesised group, optionally followed by an occurrence indicator. The model will be normalized so that all whitespace is removed,and will include the enclosing parentheses.

Specified by:
elementDecl in interface org.xml.sax.ext.DeclHandler

Parameters:
name - The element type name.
model - The content model as a normalized string.
Throws:
SAXException - The application may raise an exception.

attributeDecl

public void attributeDecl(java.lang.String eName,
                          java.lang.String aName,
                          java.lang.String type,
                          java.lang.String valueDefault,
                          java.lang.String value)
                   throws org.xml.sax.SAXException
Report an attribute type declaration.

Only the effective (first) declaration for an attribute will be reported. The type will be one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", or "NOTATION", or a parenthesized token group with the separator "|" and all whitespace removed.

Specified by:
attributeDecl in interface org.xml.sax.ext.DeclHandler

Parameters:
eName - The name of the associated element.
aName - The name of the attribute.
type - A string representing the attribute type.
valueDefault - A string representing the attribute default ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if none of these applies.
value - A string representing the attribute's default value, or null if there is none.
Throws:
SAXException - The application may raise an exception.

internalEntityDecl

public void internalEntityDecl(java.lang.String name,
                               java.lang.String value)
                        throws org.xml.sax.SAXException
Report an internal entity declaration.

Only the effective (first) declaration for each entity will be reported.

Specified by:
internalEntityDecl in interface org.xml.sax.ext.DeclHandler

Parameters:
name - The name of the entity. If it is a parameter entity, the name will begin with '%'.
value - The replacement text of the entity.
Throws:
SAXException - The application may raise an exception.
See Also:
externalEntityDecl(java.lang.String, java.lang.String, java.lang.String), DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)

externalEntityDecl

public void externalEntityDecl(java.lang.String name,
                               java.lang.String publicId,
                               java.lang.String systemId)
                        throws org.xml.sax.SAXException
Report a parsed external entity declaration.

Only the effective (first) declaration for each entity will be reported.

Specified by:
externalEntityDecl in interface org.xml.sax.ext.DeclHandler

Parameters:
name - The name of the entity. If it is a parameter entity, the name will begin with '%'.
publicId - The declared public identifier of the entity, or null if none was declared.
systemId - The declared system identifier of the entity.
Throws:
SAXException - The application may raise an exception.
See Also:
internalEntityDecl(java.lang.String, java.lang.String), DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)

notationDecl

public void notationDecl(java.lang.String name,
                         java.lang.String publicId,
                         java.lang.String systemId)
                  throws org.xml.sax.SAXException
Receive notification of a notation declaration event.

It is up to the application to record the notation for later reference, if necessary.

At least one of publicId and systemId must be non-null. If a system identifier is present, and it is a URL, the SAX parser must resolve it fully before passing it to the application through this event.

There is no guarantee that the notation declaration will be reported before any unparsed entities that use it.

Specified by:
notationDecl in interface org.xml.sax.DTDHandler

Parameters:
name - The notation name.
publicId - The notation's public identifier, or null if none was given.
systemId - The notation's system identifier, or null if none was given.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
Overrides:
notationDecl in class org.xml.sax.helpers.DefaultHandler
See Also:
unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String), AttributeList

unparsedEntityDecl

public void unparsedEntityDecl(java.lang.String name,
                               java.lang.String publicId,
                               java.lang.String systemId,
                               java.lang.String notationName)
                        throws org.xml.sax.SAXException
Receive notification of an unparsed entity declaration event.

Note that the notation name corresponds to a notation reported by the notationDecl event. It is up to the application to record the entity for later reference, if necessary.

If the system identifier is a URL, the parser must resolve it fully before passing it to the application.

Specified by:
unparsedEntityDecl in interface org.xml.sax.DTDHandler

Parameters:
name - The unparsed entity's name.
publicId - The entity's public identifier, or null if none was given.
systemId - The entity's system identifier.
notation - name The name of the associated notation.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
Overrides:
unparsedEntityDecl in class org.xml.sax.helpers.DefaultHandler
See Also:
notationDecl(java.lang.String, java.lang.String, java.lang.String), AttributeList

Documentation is available at
http://download.oracle.com/docs/cd/E13222_01/wls/docs61

WebLogic classes and methods that do not appear in this reference are not public and are not supported.