|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.novell.xsl.result.SAXResultHandler
Result handler for the NXSL processor that passes on result tree events as SAX events.
There are two primary methods of using this class:
1: Construct an instance with a passed Stylesheet
(the first four constructors)
and then call parse()
, or
2: Construct an instance without an attached Stylesheet
and then set the constructed
object as the result handler for a stylesheet (Stylesheet.setResultHandler()
). The
SAX events are generated in the second case by calling Stylesheet.process()
.
Field Summary | |
protected List |
attributeNames
Names of attributes being marshalled for the DocumentHandler.startElement()
notification. |
protected List |
attributeValues
Values of attributes being marshalled for the DocumentHandler.startElement()
notification. |
protected AttributeListImpl |
attrList
AttributeList to use for DocumentHandler.startElement() notifications |
protected NamespaceStack |
currentNamespaces
Stack of namespace declarations currently in effect. |
protected DocumentHandler |
documentHandler
The SAX DocumentHandler to which to route event notifications |
protected boolean |
doPIComments
If true, send comment notifications as processing instruction events with a null target. |
protected String |
elementName
The unexpanded name of the current element |
protected ErrorHandler |
errorHandler
The SAX error handler to which to route error notifications |
protected Parser |
parser
The SAX Parser to use when parse() is called. |
protected Document |
sourceDocument
The DOM source document to use as input to the stylesheet. |
protected boolean |
startTagOpen
If true, have received a startElement() notification but have not
yet forwarded the notification to the DocumentHandler . |
protected Stack |
stateStack
Stack of state (changed by elements) |
protected Stylesheet |
stylesheet
The Stylesheet object to use in generating the events |
Constructor Summary | |
SAXResultHandler()
Construct a SAX result handler that will translate NXSL ResultHandler events into
SAX events. |
|
SAXResultHandler(Document sourceDocument,
Stylesheet stylesheet)
Construct a SAX result handler given a DOM source document and a Stylesheet object that was previous constructed and compiled. |
|
SAXResultHandler(Parser sourceParser,
Stylesheet stylesheet)
Construct a SAX result handler given a SAX Parser to use to parse the source document and a Stylesheet object that was previously constructed and compiled. |
|
SAXResultHandler(String stylesheetURL)
Construct a SAX result handler given the URL of an XSLT stylesheet. |
|
SAXResultHandler(Stylesheet stylesheet)
Construct a SAX result handler that will use the passed stylesheet to process the xml document passed to parse()
The parse() method of the resulting object can then be called to generate the
XSLT result tree events. |
Method Summary | |
void |
attribute(String name,
String value)
Receive notification of an attribute. |
void |
characters(String data)
Receive notification of character data. |
protected void |
closeStartTag()
Close any open element start tag by sending SAX startElement event |
void |
comment(String value)
Receive notification of a comment. |
void |
endDocument()
Receive notification of the end of a document. |
void |
endElement(String name)
Receive notification of the end of an element. |
protected ExpandedQName |
getExpandedName(String qName,
boolean isAttribute)
Get the expanded name for a node QName using the currently in-scope namespace nodes. |
void |
namespace(String name,
NamespaceName value)
Receive notification of a namespace node. |
void |
parse(InputSource source)
Parse an XML document. |
void |
parse(String systemId)
Parse an XML document from a system identifier (URI). |
protected void |
popState()
Restore the last element state |
void |
processingInstruction(String target,
String value)
Receive notification of a processing instruction. |
protected void |
pushState()
Save the current element state |
void |
setDocumentHandler(DocumentHandler handler)
Allow an application to register a document event handler. |
void |
setDTDHandler(DTDHandler handler)
Allow an application to register a DTD event handler. |
void |
setEntityResolver(EntityResolver resolver)
Allow an application to register a custom entity resolver. |
void |
setErrorHandler(ErrorHandler handler)
Allow an application to register an error event handler. |
void |
setLocale(Locale locale)
Allow an application to request a locale for errors and warnings. |
void |
setUsePIComment(boolean usePIComment)
Cause this object to generate comment events by calling DocumentHandler.processingInstruction()
with a null target and the comment data in the data parameter.
|
void |
startDocument()
Receive notification of the beginning of a document. |
void |
startElement(String name,
String namespaceURI)
Receive notification of the beginning of an element. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected DocumentHandler documentHandler
protected ErrorHandler errorHandler
protected boolean doPIComments
protected String elementName
protected boolean startTagOpen
startElement()
notification but have not
yet forwarded the notification to the DocumentHandler
.
protected List attributeNames
DocumentHandler.startElement()
notification.
protected List attributeValues
DocumentHandler.startElement()
notification.
protected NamespaceStack currentNamespaces
protected Stack stateStack
protected AttributeListImpl attrList
AttributeList
to use for DocumentHandler.startElement()
notifications
protected Stylesheet stylesheet
Stylesheet
object to use in generating the events
protected Parser parser
parse()
is called. If this is null
, XMLParserFactory
will
be used to get a parser to use.
protected Document sourceDocument
null
, the
argument to parse()
will be ignored.
Constructor Detail |
public SAXResultHandler(String stylesheetURL) throws IOException, XSLException
stylesheetURL
- The URL of the stylesheet document. The URL may be relative if
it is a filename.public SAXResultHandler(Parser sourceParser, Stylesheet stylesheet)
parse()
method of the resulting object can then be called to generate the
XSLT result tree events.
sourceParser
- The SAX parser that will be used to generate source document events.stylesheet
- The Stylesheet object to be applied to the source document.public SAXResultHandler(Document sourceDocument, Stylesheet stylesheet)
parse()
method of the
resulting object can then be called to generate the XSLT result tree events. Note, however,
that the parameter to parse()
will be ignored in this case, since the sourceDocument
does not need to be parsed.
sourceDocument
- The DOM source document to transform.stylesheet
- The Stylesheet object to be applied to the source document.public SAXResultHandler(Stylesheet stylesheet)
parse()
The parse()
method of the resulting object can then be called to generate the
XSLT result tree events.
stylesheet
- The Stylesheet object to be applied to the source document.public SAXResultHandler()
ResultHandler
events into
SAX events. Note that the parse()
method of the resulting object must not be
called. Instead, call Stylesheet.setResultHandler()
with the resulting object as the
parameter and then call Stylesheet.process()
to generate the SAX events.
Method Detail |
public void setUsePIComment(boolean usePIComment)
DocumentHandler.processingInstruction()
with a null
target and the comment data in the data parameter.
This method of generating comments using standard SAX events was swiped from James Clark's XP
XML parser.
usePIComment
- true
to generate comment events using
DocumentHandler.processingInstruction()
.DocumentCommentHandler
public void startDocument() throws ResultException
DocumentHandler
.
startDocument
in interface ResultHandler
ResultException
- if an implementation-dependent error occurspublic void endDocument() throws ResultException
DocumentHandler
.
endDocument
in interface ResultHandler
ResultException
- if an implementation-dependent error occurspublic void startElement(String name, String namespaceURI) throws IllegalNameException, IllegalNodeException, ResultException
DocumentHandler
since
attributes and namespace nodes have not yet been sent.
startElement
in interface ResultHandler
name
- the element's namenamespaceURI
- the element's namespace uri
IllegalNameException
- if the specified element name is illegal
IllegalNodeException
- if the current node cannot contain elements
ResultException
- if an implementation-dependent error occurspublic void endElement(String name) throws ResultException
DocumentHandler
. It may also
cause a DocumentHandler.startElement()
notification.
endElement
in interface ResultHandler
ResultException
- if an implementation-dependent error occurspublic void attribute(String name, String value) throws AttributeAfterChildException, IllegalNameException, IllegalNodeException, ResultException
DocumentHandler.startElement()
method.
attribute
in interface ResultHandler
name
- the attribute's namevalue
- the attribute's value
AttributeAfterChildException
- if the current node is an element with children
(attributes cannot be added to an element after children
have been added to it)
IllegalNameException
- if the specified attribute name is illegal
IllegalNodeException
- if the current node is not an element
ResultException
- if an implementation-dependent error occurspublic void characters(String data) throws IllegalNodeException, ResultException
DocumentHandler
. It may also cause a
DocumentHandler.startElement()
notification.
characters
in interface ResultHandler
data
- the character data
IllegalNodeException
- if the current node cannot contain character data
ResultException
- if an implementation-dependent error occurspublic void processingInstruction(String target, String value) throws IllegalNameException, IllegalNodeException, ResultException
DocumentHandler
. It may also cause a
DocumentHandler.startElement()
notification.
processingInstruction
in interface ResultHandler
target
- the processing instruction's targetvalue
- the processing instruction's value, or null
if there is no value
IllegalNameException
- if the specified target name is illegal
IllegalNodeException
- if the current node cannot contain processing
instructions
ResultException
- if an implementation-dependent error occurspublic void comment(String value) throws IllegalNodeException, ResultException
DocumentHandler
if the DocumentHandler
is an instance of com.novell.xml.sax.CommentDocumentHandler
or if
usePIComments
is true
. It may also cause a
DocumentHandler.startElement()
notification.
comment
in interface ResultHandler
value
- the comment's value
IllegalNodeException
- if the current node cannot contain comments
ResultException
- if an implementation-dependent error occurspublic void namespace(String name, NamespaceName value) throws IllegalNodeException, ResultException
startElement()
notification.
An implementation should keep track of what namespace attributes
are in scope in the xml representation to avoid placing redundant
attributes on elements.
namespace
in interface ResultHandler
name
- the namespace prefixvalue
- the namespace name (URI)
IllegalNodeException
- if the current node cannot contain namespaces
ResultException
- if an implementation-dependent error occurspublic void setLocale(Locale locale) throws SAXException
SAX parsers are not required to provide localisation for errors and warnings; if they cannot support the requested locale, however, they must throw a SAX exception. Applications may not request a locale change in the middle of a parse.
setLocale
in interface Parser
locale
- A Java Locale object.
SAXException
- Throws an exception
(using the previous or default locale) if the
requested locale is not supported.SAXException
,
SAXParseException
public void setEntityResolver(EntityResolver resolver)
If the application does not register an entity resolver, the SAX parser will resolve system identifiers and open connections to entities itself (this is the default behaviour implemented in HandlerBase).
Applications may register a new or different entity resolver in the middle of a parse, and the SAX parser must begin using the new resolver immediately.
setEntityResolver
in interface Parser
resolver
- The object for resolving entities.EntityResolver
,
HandlerBase
public void setDTDHandler(DTDHandler handler)
If the application does not register a DTD handler, all DTD events reported by the SAX parser will be silently ignored (this is the default behaviour implemented by HandlerBase).
Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.
setDTDHandler
in interface Parser
handler
- The DTD handler.DTDHandler
,
HandlerBase
public void setDocumentHandler(DocumentHandler handler)
If the application does not register a document handler, all document events reported by the SAX parser will be silently ignored (this is the default behaviour implemented by HandlerBase).
Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.
setDocumentHandler
in interface Parser
handler
- The document handler.DocumentHandler
,
HandlerBase
public void setErrorHandler(ErrorHandler handler)
If the application does not register an error event handler, all error events reported by the SAX parser will be silently ignored, except for fatalError, which will throw a SAXException (this is the default behaviour implemented by HandlerBase).
Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.
setErrorHandler
in interface Parser
handler
- The error handler.ErrorHandler
,
SAXException
,
HandlerBase
public void parse(InputSource source) throws SAXException, IOException
The application can use this method to instruct the SAX parser to begin parsing an XML document from any valid input source (a character stream, a byte stream, or a URI).
Applications may not invoke this method while a parse is in progress (they should create a new Parser instead for each additional XML document). Once a parse is complete, an application may reuse the same Parser object, possibly with a different input source.
parse
in interface Parser
source
- The input source for the top-level of the
XML document.
SAXException
- Any SAX exception, possibly
wrapping another exception.
IOException
- An IO exception from the parser,
possibly from a byte stream or character stream
supplied by the application.InputSource
,
parse(java.lang.String)
,
setEntityResolver(org.xml.sax.EntityResolver)
,
setDTDHandler(org.xml.sax.DTDHandler)
,
setDocumentHandler(org.xml.sax.DocumentHandler)
,
setErrorHandler(org.xml.sax.ErrorHandler)
public void parse(String systemId) throws SAXException, IOException
This method is a shortcut for the common case of reading a document from a system identifier. It is the exact equivalent of the following:
parse(new InputSource(systemId));
If the system identifier is a URL, it must be fully resolved by the application before it is passed to the parser.
parse
in interface Parser
systemId
- The system identifier (URI).
SAXException
- Any SAX exception, possibly
wrapping another exception.
IOException
- An IO exception from the parser,
possibly from a byte stream or character stream
supplied by the application.parse(org.xml.sax.InputSource)
protected void closeStartTag() throws ResultException
ResultException
protected ExpandedQName getExpandedName(String qName, boolean isAttribute) throws IllegalNameException
qName
- The QName to expandisAttribute
- True if the name is for an attribute node
IllegalNameException
protected void pushState()
protected void popState()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |