Class JDOMResult.DocumentBuilder

java.lang.Object
  extended by org.xml.sax.helpers.XMLFilterImpl
      extended by JDOMResult.DocumentBuilder
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler, org.xml.sax.XMLFilter, org.xml.sax.XMLReader
Enclosing class:
JDOMResult

private class JDOMResult.DocumentBuilder
extends org.xml.sax.helpers.XMLFilterImpl
implements org.xml.sax.ext.LexicalHandler


Field Summary
private  JDOMResult.FragmentHandler saxHandler
          The actual JDOM document builder.
private  boolean startDocumentReceived
          Whether the startDocument event was received.
 
Constructor Summary
JDOMResult.DocumentBuilder()
          Public default constructor.
 
Method Summary
 void characters(char[] ch, int start, int length)
          [SAX ContentHandler interface support] Receives notification of character data.
 void comment(char[] ch, int start, int length)
          [SAX LexicalHandler interface support] Reports an XML comment anywhere in the document.
 void endCDATA()
          [SAX LexicalHandler interface support] Reports the end of a CDATA section.
 void endDTD()
          [SAX LexicalHandler interface support] Reports the end of DTD declarations.
 void endEntity(java.lang.String name)
          [SAX LexicalHandler interface support] Reports the end of an entity.
private  void ensureInitialization()
           
 java.util.List getResult()
          Returns the result of an XSL Transformation.
 void ignorableWhitespace(char[] ch, int start, int length)
          [SAX ContentHandler interface support] Receives notification of ignorable whitespace in element content.
 void processingInstruction(java.lang.String target, java.lang.String data)
          [SAX ContentHandler interface support] Receives notification of a processing instruction.
 void skippedEntity(java.lang.String name)
          [SAX ContentHandler interface support] Receives notification of a skipped entity.
 void startCDATA()
          [SAX LexicalHandler interface support] Reports the start of a CDATA section.
 void startDocument()
          [SAX ContentHandler interface support] Processes a start of document event.
 void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          [SAX LexicalHandler interface support] Reports the start of DTD declarations, if any.
 void startElement(java.lang.String nsURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
          [SAX ContentHandler interface support] Receives notification of the beginning of an element.
 void startEntity(java.lang.String name)
          [SAX LexicalHandler interface support] Reports the beginning of some internal and external XML entities.
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          [SAX ContentHandler interface support] Begins the scope of a prefix-URI Namespace mapping.
 
Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
endDocument, endElement, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, notationDecl, parse, parse, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, setProperty, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

saxHandler

private JDOMResult.FragmentHandler saxHandler
The actual JDOM document builder.


startDocumentReceived

private boolean startDocumentReceived
Whether the startDocument event was received. Some XSLT processors such as Oracle's do not fire this event.

Constructor Detail

JDOMResult.DocumentBuilder

public JDOMResult.DocumentBuilder()
Public default constructor.

Method Detail

getResult

public java.util.List getResult()
Returns the result of an XSL Transformation.

Returns:
the transformation result as a (possibly empty) list of JDOM nodes (Elements, Texts, Comments, PIs...) or null if no new transformation occurred since the result of the previous one was returned.

ensureInitialization

private void ensureInitialization()
                           throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
[SAX ContentHandler interface support] Processes a start of document event.

This implementation creates a new JDOM document builder and marks the current result as "under construction".

Specified by:
startDocument in interface org.xml.sax.ContentHandler
Overrides:
startDocument in class org.xml.sax.helpers.XMLFilterImpl
Throws:
org.xml.sax.SAXException - if any error occurred while creating the document builder.

startElement

public void startElement(java.lang.String nsURI,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
[SAX ContentHandler interface support] Receives notification of the beginning of an element.

This implementation ensures that startDocument() has been called prior processing an element.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.XMLFilterImpl
Parameters:
nsURI - the Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
localName - the local name (without prefix), or the empty string if Namespace processing is not being performed.
qName - the qualified name (with prefix), or the empty string if qualified names are not available.
atts - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
Throws:
org.xml.sax.SAXException - if any error occurred while creating the document builder.

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
[SAX ContentHandler interface support] Begins the scope of a prefix-URI Namespace mapping.

Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler
Overrides:
startPrefixMapping in class org.xml.sax.helpers.XMLFilterImpl
Throws:
org.xml.sax.SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
[SAX ContentHandler interface support] Receives notification of character data.

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.XMLFilterImpl
Throws:
org.xml.sax.SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
[SAX ContentHandler interface support] Receives notification of ignorable whitespace in element content.

Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
Overrides:
ignorableWhitespace in class org.xml.sax.helpers.XMLFilterImpl
Throws:
org.xml.sax.SAXException

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
[SAX ContentHandler interface support] Receives notification of a processing instruction.

Specified by:
processingInstruction in interface org.xml.sax.ContentHandler
Overrides:
processingInstruction in class org.xml.sax.helpers.XMLFilterImpl
Throws:
org.xml.sax.SAXException

skippedEntity

public void skippedEntity(java.lang.String name)
                   throws org.xml.sax.SAXException
[SAX ContentHandler interface support] Receives notification of a skipped entity.

Specified by:
skippedEntity in interface org.xml.sax.ContentHandler
Overrides:
skippedEntity in class org.xml.sax.helpers.XMLFilterImpl
Throws:
org.xml.sax.SAXException

startDTD

public void startDTD(java.lang.String name,
                     java.lang.String publicId,
                     java.lang.String systemId)
              throws org.xml.sax.SAXException
[SAX LexicalHandler interface support] Reports the start of DTD declarations, if any.

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:
org.xml.sax.SAXException - The application may raise an exception.

endDTD

public void endDTD()
            throws org.xml.sax.SAXException
[SAX LexicalHandler interface support] Reports the end of DTD declarations.

Specified by:
endDTD in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException - The application may raise an exception.

startEntity

public void startEntity(java.lang.String name)
                 throws org.xml.sax.SAXException
[SAX LexicalHandler interface support] Reports the beginning of some internal and external XML entities.

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 '%', and if it is the external DTD subset, it will be "[dtd]".
Throws:
org.xml.sax.SAXException - The application may raise an exception.

endEntity

public void endEntity(java.lang.String name)
               throws org.xml.sax.SAXException
[SAX LexicalHandler interface support] Reports 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:
org.xml.sax.SAXException - The application may raise an exception.

startCDATA

public void startCDATA()
                throws org.xml.sax.SAXException
[SAX LexicalHandler interface support] Reports the start of a CDATA section.

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

endCDATA

public void endCDATA()
              throws org.xml.sax.SAXException
[SAX LexicalHandler interface support] Reports the end of a CDATA section.

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

comment

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

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:
org.xml.sax.SAXException - The application may raise an exception.