org.apache.xalan.stree
Class SourceTreeHandler

java.lang.Object
  |
  +--org.apache.xalan.stree.SourceTreeHandler

public class SourceTreeHandler
extends java.lang.Object
implements ContentHandler, org.xml.sax.ext.LexicalHandler

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


Constructor Summary
SourceTreeHandler()
          Create a SourceTreeHandler.
SourceTreeHandler(TransformerImpl transformer)
          Create a SourceTreeHandler that will start a transformation as soon as a startDocument occurs.
 
Method Summary
 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 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.
 InputSource getInputSource()
           
 Node getRoot()
          Get the root document of tree that is being or will be created.
 TransformerImpl getTransformer()
           
 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 processingInstruction(java.lang.String target, java.lang.String data)
          Implement the processingInstruction event.
 void setDocumentLocator(Locator locator)
          Implement the setDocumentLocator event.
 void setInputSource(InputSource source)
           
 void setRoot(Document root)
          Set the root document of tree will be created.
 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, 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.
 
Methods inherited from class java.lang.Object
equals, 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.

SourceTreeHandler

public SourceTreeHandler()
Create a SourceTreeHandler.
Method Detail

getTransformer

public TransformerImpl getTransformer()

getRoot

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

setRoot

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

setInputSource

public void setInputSource(InputSource source)

getInputSource

public InputSource getInputSource()

setDocumentLocator

public void setDocumentLocator(Locator locator)
Implement the setDocumentLocator event.
Specified by:
setDocumentLocator in interface ContentHandler

setUseMultiThreading

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

getUseMultiThreading

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

startDocument

public void startDocument()
                   throws SAXException
Implement the startDocument event.
Specified by:
startDocument in interface ContentHandler

endDocument

public void endDocument()
                 throws SAXException
Implement the endDocument event.
Specified by:
endDocument in interface ContentHandler

startElement

public void startElement(java.lang.String ns,
                         java.lang.String localName,
                         java.lang.String name,
                         Attributes atts)
                  throws SAXException
Implement the startElement event.
Specified by:
startElement in interface ContentHandler

endElement

public void endElement(java.lang.String ns,
                       java.lang.String localName,
                       java.lang.String name)
                throws SAXException
Implement the endElement event.
Specified by:
endElement in interface ContentHandler

startCDATA

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

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

Specified by:
startCDATA in interface org.xml.sax.ext.LexicalHandler
Throws:
SAXException - The application may raise an exception.
See Also:
endCDATA()

endCDATA

public void endCDATA()
              throws SAXException
Report the end of a CDATA section.
Specified by:
endCDATA in interface org.xml.sax.ext.LexicalHandler
Throws:
SAXException - The application may raise an exception.
See Also:
startCDATA()

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Implement the characters event.
Specified by:
characters in interface ContentHandler

charactersRaw

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

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws SAXException
Implement the ignorableWhitespace event.
Specified by:
ignorableWhitespace in interface ContentHandler

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws SAXException
Implement the processingInstruction event.
Specified by:
processingInstruction in interface ContentHandler

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws 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).

Specified by:
comment in interface org.xml.sax.ext.LexicalHandler
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:
SAXException - The application may raise an exception.

startEntity

public void startEntity(java.lang.String name)
                 throws 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.

Specified by:
startEntity in interface org.xml.sax.ext.LexicalHandler
Parameters:
name - The name of the entity. If it is a parameter entity, the name will begin with '%'.
Throws:
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 SAXException
Report the end of an entity.
Specified by:
endEntity in interface org.xml.sax.ext.LexicalHandler
Parameters:
name - The name of the entity that is ending.
Throws:
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 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.

Specified by:
startDTD in interface org.xml.sax.ext.LexicalHandler
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:
SAXException - The application may raise an exception.
See Also:
endDTD(), startEntity(java.lang.String)

endDTD

public void endDTD()
            throws SAXException
Report the end of DTD declarations.
Specified by:
endDTD in interface org.xml.sax.ext.LexicalHandler
Throws:
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 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.

Specified by:
startPrefixMapping in interface ContentHandler
Parameters:
prefix - The Namespace prefix being declared.
uri - The Namespace URI the prefix is mapped to.
Throws:
SAXException - The client may throw an exception during processing.
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 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.

Specified by:
endPrefixMapping in interface ContentHandler
Parameters:
prefix - The prefix that was being mapping.
Throws:
SAXException - The client may throw an exception during processing.
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 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.

Specified by:
skippedEntity in interface ContentHandler
Parameters:
name - The name of the skipped entity. If it is a parameter entity, the name will begin with '%'.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.


Copyright © 2000 Apache XML Project. All Rights Reserved.