Class TransformerHandlerImpl
- java.lang.Object
-
- org.apache.xalan.transformer.TransformerHandlerImpl
-
- All Implemented Interfaces:
javax.xml.transform.sax.TransformerHandler,org.xml.sax.ContentHandler,org.xml.sax.DTDHandler,org.xml.sax.EntityResolver,org.xml.sax.ErrorHandler,org.xml.sax.ext.DeclHandler,org.xml.sax.ext.LexicalHandler
public class TransformerHandlerImpl extends java.lang.Object implements org.xml.sax.EntityResolver, org.xml.sax.DTDHandler, org.xml.sax.ContentHandler, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler, javax.xml.transform.sax.TransformerHandler, org.xml.sax.ext.DeclHandlerA TransformerHandler listens for SAX ContentHandler parse events and transforms them to a Result.
-
-
Constructor Summary
Constructors Constructor Description TransformerHandlerImpl(TransformerImpl transformer, boolean doFragment, java.lang.String baseSystemID)Construct a TransformerHandlerImpl.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattributeDecl(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.voidcharacters(char[] ch, int start, int length)Filter a character data event.voidcomment(char[] ch, int start, int length)Report an XML comment anywhere in the document.voidelementDecl(java.lang.String name, java.lang.String model)Report an element type declaration.voidendCDATA()Report the end of a CDATA section.voidendDocument()Filter an end document event.voidendDTD()Report the end of DTD declarations.voidendElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)Filter an end element event.voidendEntity(java.lang.String name)Report the end of an entity.voidendPrefixMapping(java.lang.String prefix)Filter an end Namespace prefix mapping event.voiderror(org.xml.sax.SAXParseException e)Filter an error event.voidexternalEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)Report a parsed external entity declaration.voidfatalError(org.xml.sax.SAXParseException e)Filter a fatal error event.java.lang.StringgetSystemId()Get the base ID (URI or system ID) from where relative URLs will be resolved.javax.xml.transform.TransformergetTransformer()Get the Transformer associated with this handler, which is needed in order to set parameters and output properties.voidignorableWhitespace(char[] ch, int start, int length)Filter an ignorable whitespace event.voidinternalEntityDecl(java.lang.String name, java.lang.String value)Report an internal entity declaration.voidnotationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)Filter a notation declaration event.voidprocessingInstruction(java.lang.String target, java.lang.String data)Filter a processing instruction event.org.xml.sax.InputSourceresolveEntity(java.lang.String publicId, java.lang.String systemId)Filter an external entity resolution.voidsetDocumentLocator(org.xml.sax.Locator locator)Filter a new document locator event.voidsetResult(javax.xml.transform.Result result)Enables the user of the TransformerHandler to set the to set the Result for the transformation.voidsetSystemId(java.lang.String systemID)Set the base ID (URI or system ID) from where relative URLs will be resolved.voidskippedEntity(java.lang.String name)Filter a skipped entity event.voidstartCDATA()Report the start of a CDATA section.voidstartDocument()Filter a start document event.voidstartDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)Report the start of DTD declarations, if any.voidstartElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)Filter a start element event.voidstartEntity(java.lang.String name)Report the beginning of an entity in content.voidstartPrefixMapping(java.lang.String prefix, java.lang.String uri)Filter a start Namespace prefix mapping event.voidunparsedEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notationName)Filter an unparsed entity declaration event.voidwarning(org.xml.sax.SAXParseException e)Filter a warning event.
-
-
-
Constructor Detail
-
TransformerHandlerImpl
public TransformerHandlerImpl(TransformerImpl transformer, boolean doFragment, java.lang.String baseSystemID)
Construct a TransformerHandlerImpl.- Parameters:
transformer- Non-null reference to the Xalan transformer impl.doFragment- True if the result should be a document fragement.baseSystemID- The system ID to use as the base for relative URLs.
-
-
Method Detail
-
setResult
public void setResult(javax.xml.transform.Result result) throws java.lang.IllegalArgumentExceptionEnables the user of the TransformerHandler to set the to set the Result for the transformation.- Specified by:
setResultin interfacejavax.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 systemID)
Set the base ID (URI or system ID) from where relative URLs will be resolved.- Specified by:
setSystemIdin interfacejavax.xml.transform.sax.TransformerHandler- Parameters:
systemID- Base URI 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:
getSystemIdin interfacejavax.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:
getTransformerin interfacejavax.xml.transform.sax.TransformerHandler- Returns:
- The Transformer associated with this handler
-
resolveEntity
public org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException, java.io.IOExceptionFilter an external entity resolution.- Specified by:
resolveEntityin interfaceorg.xml.sax.EntityResolver- Parameters:
publicId- The entity's public identifier, or null.systemId- The entity's system identifier.- Returns:
- A new InputSource or null for the default.
- Throws:
java.io.IOExceptionorg.xml.sax.SAXException- The client may throw an exception during processing.java.io.IOException- The client may throw an I/O-related exception while obtaining the new InputSource.- See Also:
EntityResolver.resolveEntity(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.SAXExceptionFilter a notation declaration event.- Specified by:
notationDeclin interfaceorg.xml.sax.DTDHandler- Parameters:
name- The notation name.publicId- The notation's public identifier, or null.systemId- The notation's system identifier, or null.- Throws:
org.xml.sax.SAXException- The client may throw an exception during processing.- See Also:
DTDHandler.notationDecl(java.lang.String, java.lang.String, java.lang.String)
-
unparsedEntityDecl
public void unparsedEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notationName) throws org.xml.sax.SAXExceptionFilter an unparsed entity declaration event.- Specified by:
unparsedEntityDeclin interfaceorg.xml.sax.DTDHandler- Parameters:
name- The entity name.publicId- The entity's public identifier, or null.systemId- The entity's system identifier, or null.notationName- The name of the associated notation.- Throws:
org.xml.sax.SAXException- The client may throw an exception during processing.- See Also:
DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
-
setDocumentLocator
public void setDocumentLocator(org.xml.sax.Locator locator)
Filter a new document locator event.- Specified by:
setDocumentLocatorin interfaceorg.xml.sax.ContentHandler- Parameters:
locator- The document locator.- See Also:
ContentHandler.setDocumentLocator(org.xml.sax.Locator)
-
startDocument
public void startDocument() throws org.xml.sax.SAXExceptionFilter a start document event.- Specified by:
startDocumentin interfaceorg.xml.sax.ContentHandler- Throws:
org.xml.sax.SAXException- The client may throw an exception during processing.- See Also:
ContentHandler.startDocument()
-
endDocument
public void endDocument() throws org.xml.sax.SAXExceptionFilter an end document event.- Specified by:
endDocumentin interfaceorg.xml.sax.ContentHandler- Throws:
org.xml.sax.SAXException- The client may throw an exception during processing.- See Also:
ContentHandler.endDocument()
-
startPrefixMapping
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXExceptionFilter a start Namespace prefix mapping event.- Specified by:
startPrefixMappingin interfaceorg.xml.sax.ContentHandler- Parameters:
prefix- The Namespace prefix.uri- The Namespace URI.- Throws:
org.xml.sax.SAXException- The client may throw an exception during processing.- See Also:
ContentHandler.startPrefixMapping(java.lang.String, java.lang.String)
-
endPrefixMapping
public void endPrefixMapping(java.lang.String prefix) throws org.xml.sax.SAXExceptionFilter an end Namespace prefix mapping event.- Specified by:
endPrefixMappingin interfaceorg.xml.sax.ContentHandler- Parameters:
prefix- The Namespace prefix.- Throws:
org.xml.sax.SAXException- The client may throw an exception during processing.- See Also:
ContentHandler.endPrefixMapping(java.lang.String)
-
startElement
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts) throws org.xml.sax.SAXExceptionFilter a start element event.- Specified by:
startElementin interfaceorg.xml.sax.ContentHandler- Parameters:
uri- The element's Namespace URI, or the empty string.localName- The element's local name, or the empty string.qName- The element's qualified (prefixed) name, or the empty string.atts- The element's attributes.- Throws:
org.xml.sax.SAXException- The client may throw an exception during processing.- See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
-
endElement
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXExceptionFilter an end element event.- Specified by:
endElementin interfaceorg.xml.sax.ContentHandler- Parameters:
uri- The element's Namespace URI, or the empty string.localName- The element's local name, or the empty string.qName- The element's qualified (prefixed) name, or the empty string.- Throws:
org.xml.sax.SAXException- The client may throw an exception during processing.- See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
-
characters
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXExceptionFilter a character data event.- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler- Parameters:
ch- An array of characters.start- The starting position in the array.length- The number of characters to use from the array.- Throws:
org.xml.sax.SAXException- The client may throw an exception during processing.- See Also:
ContentHandler.characters(char[], int, int)
-
ignorableWhitespace
public void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXExceptionFilter an ignorable whitespace event.- Specified by:
ignorableWhitespacein interfaceorg.xml.sax.ContentHandler- Parameters:
ch- An array of characters.start- The starting position in the array.length- The number of characters to use from the array.- Throws:
org.xml.sax.SAXException- The client may throw an exception during processing.- See Also:
ContentHandler.ignorableWhitespace(char[], int, int)
-
processingInstruction
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXExceptionFilter a processing instruction event.- Specified by:
processingInstructionin interfaceorg.xml.sax.ContentHandler- Parameters:
target- The processing instruction target.data- The text following the target.- Throws:
org.xml.sax.SAXException- The client may throw an exception during processing.- See Also:
ContentHandler.processingInstruction(java.lang.String, java.lang.String)
-
skippedEntity
public void skippedEntity(java.lang.String name) throws org.xml.sax.SAXExceptionFilter a skipped entity event.- Specified by:
skippedEntityin interfaceorg.xml.sax.ContentHandler- Parameters:
name- The name of the skipped entity.- Throws:
org.xml.sax.SAXException- The client may throw an exception during processing.- See Also:
ContentHandler.skippedEntity(java.lang.String)
-
warning
public void warning(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXExceptionFilter a warning event.- Specified by:
warningin interfaceorg.xml.sax.ErrorHandler- Parameters:
e- The nwarning as an exception.- Throws:
org.xml.sax.SAXException- The client may throw an exception during processing.- See Also:
ErrorHandler.warning(org.xml.sax.SAXParseException)
-
error
public void error(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXExceptionFilter an error event.- Specified by:
errorin interfaceorg.xml.sax.ErrorHandler- Parameters:
e- The error as an exception.- Throws:
org.xml.sax.SAXException- The client may throw an exception during processing.- See Also:
ErrorHandler.error(org.xml.sax.SAXParseException)
-
fatalError
public void fatalError(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXExceptionFilter a fatal error event.- Specified by:
fatalErrorin interfaceorg.xml.sax.ErrorHandler- Parameters:
e- The error as an exception.- Throws:
org.xml.sax.SAXException- The client may throw an exception during processing.- See Also:
ErrorHandler.fatalError(org.xml.sax.SAXParseException)
-
startDTD
public void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXExceptionReport the start of DTD declarations, if any.Any declarations are assumed to be in the internal subset unless otherwise indicated by a
startEntityevent.Note that the start/endDTD events will appear within the start/endDocument events from ContentHandler and before the first startElement event.
- Specified by:
startDTDin interfaceorg.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.- See Also:
endDTD(),startEntity(java.lang.String)
-
endDTD
public void endDTD() throws org.xml.sax.SAXExceptionReport the end of DTD declarations.- Specified by:
endDTDin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException- The application may raise an exception.- See Also:
startDTD(java.lang.String, java.lang.String, java.lang.String)
-
startEntity
public void startEntity(java.lang.String name) throws org.xml.sax.SAXExceptionReport the beginning of an entity in content.NOTE: entity references in attribute values -- and the start and end of the document entity -- are never 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
skippedEntityevent, which is part of the ContentHandler interface.- Specified by:
startEntityin interfaceorg.xml.sax.ext.LexicalHandler- 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.SAXExceptionReport the end of an entity.- Specified by:
endEntityin interfaceorg.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.- See Also:
startEntity(java.lang.String)
-
startCDATA
public void startCDATA() throws org.xml.sax.SAXExceptionReport the start of a CDATA section.The contents of the CDATA section will be reported through the regular
charactersevent.- Specified by:
startCDATAin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException- The application may raise an exception.- See Also:
endCDATA()
-
endCDATA
public void endCDATA() throws org.xml.sax.SAXExceptionReport the end of a CDATA section.- Specified by:
endCDATAin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException- The application may raise an exception.- See Also:
startCDATA()
-
comment
public void comment(char[] ch, int start, int length) throws org.xml.sax.SAXExceptionReport 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:
commentin interfaceorg.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.
-
elementDecl
public void elementDecl(java.lang.String name, java.lang.String model) throws org.xml.sax.SAXExceptionReport 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:
elementDeclin interfaceorg.xml.sax.ext.DeclHandler- Parameters:
name- The element type name.model- The content model as a normalized string.- Throws:
org.xml.sax.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.SAXExceptionReport 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:
attributeDeclin interfaceorg.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:
org.xml.sax.SAXException- The application may raise an exception.
-
internalEntityDecl
public void internalEntityDecl(java.lang.String name, java.lang.String value) throws org.xml.sax.SAXExceptionReport an internal entity declaration.Only the effective (first) declaration for each entity will be reported.
- Specified by:
internalEntityDeclin interfaceorg.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:
org.xml.sax.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.SAXExceptionReport a parsed external entity declaration.Only the effective (first) declaration for each entity will be reported.
- Specified by:
externalEntityDeclin interfaceorg.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:
org.xml.sax.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)
-
-