Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.apache.xalan.processor.StylesheetHandler
public class StylesheetHandler
extends DefaultHandler
implements TemplatesHandler, PrefixResolver, NodeConsumer
Constructor Summary | |
|
Method Summary | |
void |
|
XPath |
|
void |
|
void |
|
void |
|
void |
|
void |
|
String |
|
SAXSourceLocator |
|
String |
|
String |
|
Node |
|
StylesheetRoot |
|
String |
|
Templates |
|
boolean | |
void |
|
boolean |
|
void |
|
void |
|
void |
|
InputSource |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
Methods inherited from class org.xml.sax.helpers.DefaultHandler | |
characters , endDocument , endElement , endPrefixMapping , error , fatalError , ignorableWhitespace , notationDecl , processingInstruction , resolveEntity , setDocumentLocator , skippedEntity , startDocument , startElement , startPrefixMapping , unparsedEntityDecl , warning |
public StylesheetHandler(TransformerFactoryImpl processor) throws TransformerConfigurationException
Create a StylesheetHandler object, creating a root stylesheet as the target.
- Parameters:
processor
- non-null reference to the transformer factory that owns this handler.
- Throws:
TransformerConfigurationException
- if a StylesheetRoot can not be constructed for some reason.
public void characters(ch[] , int start, int length) throws SAXException
Receive notification of character data inside an element.
- Specified by:
- characters in interface ContentHandler
- Overrides:
- characters in interface DefaultHandler
- Parameters:
start
- The start position in the character array.length
- The number of characters to use from the character array.
- Throws:
SAXException
- Any SAX exception, possibly wrapping another exception.
public XPath createXPath(String str, ElemTemplateElement owningTemplate) throws TransformerException
Process an expression string into an XPath. Must be public for access by the AVT class.
- Parameters:
str
- A non-null reference to a valid or invalid XPath expression string.
- Returns:
- A non-null reference to an XPath object that represents the string argument.
- Throws:
TransformerException
- if the expression can not be processed.
public void endDocument() throws SAXException
Receive notification of the end of the document.
- Specified by:
- endDocument in interface ContentHandler
- Overrides:
- endDocument in interface DefaultHandler
- Throws:
SAXException
- Any SAX exception, possibly wrapping another exception.
- See Also:
ContentHandler.endDocument()
public void endElement(String uri, String localName, String rawName) throws SAXException
Receive notification of the end of an element.
- Specified by:
- endElement in interface ContentHandler
- Overrides:
- endElement in interface DefaultHandler
- Parameters:
uri
- The Namespace URI, or an empty string.localName
- The local name (without prefix), or empty string if not namespace processing.rawName
- The qualified name (with prefix).
- Throws:
SAXException
- Any SAX exception, possibly wrapping another exception.
public void endPrefixMapping(String prefix) throws SAXException
Receive notification of the end of a Namespace mapping. By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each element (such as allocating a new tree node or writing output to a file).
- Specified by:
- endPrefixMapping in interface ContentHandler
- Overrides:
- endPrefixMapping in interface DefaultHandler
- Parameters:
prefix
- The Namespace prefix being declared.
- Throws:
SAXException
- Any SAX exception, possibly wrapping another exception.
public void error(SAXParseException e) throws SAXException
Receive notification of a recoverable XSLT processing error.
- Specified by:
- error in interface ErrorHandler
- Overrides:
- error in interface DefaultHandler
- Parameters:
e
- The error information encoded as an exception.
- Throws:
SAXException
- that wraps aTransformerException
if the currentErrorListener.error(TransformerException)
method chooses to flag this condition as an error.
public void fatalError(SAXParseException e) throws SAXException
Report a fatal XSLT processing error.
- Specified by:
- fatalError in interface ErrorHandler
- Overrides:
- fatalError in interface DefaultHandler
- Parameters:
e
- The error information encoded as an exception.
- Throws:
SAXException
- that wraps aTransformerException
if the currentErrorListener.fatalError(TransformerException)
method chooses to flag this condition as an error.
public String getBaseIdentifier()
Return the base identifier.
- Specified by:
- getBaseIdentifier in interface PrefixResolver
- Returns:
- The base identifier of the current stylesheet.
public SAXSourceLocator getLocator()
Get the current stylesheet Locator object.
- Returns:
- non-null reference to the current locator object.
public String getNamespaceForPrefix(String prefix)
Given a namespace, get the corrisponding prefix from the current namespace support context.
- Specified by:
- getNamespaceForPrefix in interface PrefixResolver
- Parameters:
prefix
- The prefix to look up, which may be an empty string ("") for the default Namespace.
- Returns:
- The associated Namespace URI, or null if the prefix is undeclared in this context.
public String getNamespaceForPrefix(String prefix, Node context)
Given a namespace, get the corrisponding prefix. This is here only to support thePrefixResolver
interface, and will throw an error if invoked on this object.
- Specified by:
- getNamespaceForPrefix in interface PrefixResolver
- Parameters:
prefix
- The prefix to look up, which may be an empty string ("") for the default Namespace.context
- The node context from which to look up the URI.
- Returns:
- The associated Namespace URI, or null if the prefix is undeclared in this context.
public Node getOriginatingNode()
Set the node that is originating the SAX event.
- Returns:
- Reference to node that originated the current event.
- See Also:
NodeConsumer
public StylesheetRoot getStylesheetRoot()
Return the stylesheet root that this handler is constructing.
- Returns:
- The root stylesheet of the stylesheets tree.
public String getSystemId()
Get the base ID (URI or system ID) from where relative URLs will be resolved.
- Specified by:
- getSystemId in interface TemplatesHandler
- Returns:
- The systemID that was set with
setSystemId(String)
.
public Templates getTemplates()
When this object is used as a ContentHandler or ContentHandler, it will create a Templates object, which the caller can get once the SAX events have been completed.
- Specified by:
- getTemplates in interface TemplatesHandler
- Returns:
- The stylesheet object that was created during the SAX event process, or null if no stylesheet has been created. Author Scott Boag
public boolean handlesNullPrefixes()
- Specified by:
- handlesNullPrefixes in interface PrefixResolver
- See Also:
PrefixResolver.handlesNullPrefixes()
public void ignorableWhitespace(ch[] , int start, int length) throws SAXException
Receive notification of ignorable whitespace in element content.
- Specified by:
- ignorableWhitespace in interface ContentHandler
- Overrides:
- ignorableWhitespace in interface DefaultHandler
- Parameters:
start
- The start position in the character array.length
- The number of characters to use from the character array.
- Throws:
SAXException
- Any SAX exception, possibly wrapping another exception.
public boolean isStylesheetParsingComplete()
Test whether the _last_ endDocument() has been processed. This is needed as guidance for stylesheet optimization and compilation engines, which generally don't want to start until all included and imported stylesheets have been fully parsed.
- Returns:
- true iff the complete stylesheet tree has been built.
public void notationDecl(String name, String publicId, String systemId)
Receive notification of a notation declaration. By default, do nothing. Application writers may override this method in a subclass if they wish to keep track of the notations declared in a document.
- Specified by:
- notationDecl in interface DTDHandler
- Overrides:
- notationDecl in interface DefaultHandler
- Parameters:
name
- The notation name.publicId
- The notation public identifier, or null if not available.systemId
- The notation system identifier.
public void processingInstruction(String target, String data) throws SAXException
Receive notification of a processing instruction. The Parser will invoke this method once for each processing instruction found: note that processing instructions may occur before or after the main document element. A SAX parser should never report an XML declaration (XML 1.0, section 2.8) or a text declaration (XML 1.0, section 4.3.1) using this method. By default, do nothing. Application writers may override this method in a subclass to take specific actions for each processing instruction, such as setting status variables or invoking other methods.
- Specified by:
- processingInstruction in interface ContentHandler
- Overrides:
- processingInstruction in interface DefaultHandler
- Parameters:
target
- The processing instruction target.data
- The processing instruction data, or null if none is supplied.
- Throws:
SAXException
- Any SAX exception, possibly wrapping another exception.
public void pushStylesheet(Stylesheet s)
Push the current stylesheet being constructed. If no other stylesheets have been pushed onto the stack, assume the argument is a stylesheet root, and also set the stylesheet root member.
- Parameters:
s
- non-null reference to a stylesheet.
public InputSource resolveEntity(String publicId, String systemId) throws SAXException
Resolve an external entity.
- Specified by:
- resolveEntity in interface EntityResolver
- Overrides:
- resolveEntity in interface DefaultHandler
- Parameters:
publicId
- The public identifer, or null if none is available.systemId
- The system identifier provided in the XML document.
- Returns:
- The new input source, or null to require the default behaviour.
- Throws:
SAXException
- if the entity can not be resolved.
public void setDocumentLocator(Locator locator)
Receive a Locator object for document events. This is called by the parser to push a locator for the stylesheet being parsed. The stack needs to be popped after the stylesheet has been parsed. We pop in popStylesheet.
- Specified by:
- setDocumentLocator in interface ContentHandler
- Overrides:
- setDocumentLocator in interface DefaultHandler
- Parameters:
locator
- A locator for all SAX document events.
public void setOriginatingNode(Node n)
Set the node that is originating the SAX event.
- Specified by:
- setOriginatingNode in interface NodeConsumer
- Parameters:
n
- Reference to node that originated the current event.
- See Also:
NodeConsumer
public void setSystemId(String baseID)
Set the base ID (URL or system ID) for the stylesheet created by this builder. This must be set in order to resolve relative URLs in the stylesheet.
- Specified by:
- setSystemId in interface TemplatesHandler
- Parameters:
baseID
- Base URL for this stylesheet.
public void skippedEntity(String name) throws SAXException
Receive notification of a skipped entity. By default, do nothing. Application writers may override this method in a subclass to take specific actions for each processing instruction, such as setting status variables or invoking other methods.
- Specified by:
- skippedEntity in interface ContentHandler
- Overrides:
- skippedEntity in interface DefaultHandler
- Parameters:
name
- The name of the skipped entity.
- Throws:
SAXException
- Any SAX exception, possibly wrapping another exception.
public void startDocument() throws SAXException
Receive notification of the beginning of the document.
- Specified by:
- startDocument in interface ContentHandler
- Overrides:
- startDocument in interface DefaultHandler
- Throws:
SAXException
- Any SAX exception, possibly wrapping another exception.
- See Also:
ContentHandler.startDocument()
public void startElement(String uri, String localName, String rawName, Attributes attributes) throws SAXException
Receive notification of the start of an element.
- Specified by:
- startElement in interface ContentHandler
- Overrides:
- startElement in interface DefaultHandler
- Parameters:
uri
- The Namespace URI, or an empty string.localName
- The local name (without prefix), or empty string if not namespace processing.rawName
- The qualified name (with prefix).attributes
- The specified or defaulted attributes.
- Throws:
SAXException
-
public void startPrefixMapping(String prefix, String uri) throws SAXException
Receive notification of the start of a Namespace mapping. By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each element (such as allocating a new tree node or writing output to a file).
- Specified by:
- startPrefixMapping in interface ContentHandler
- Overrides:
- startPrefixMapping in interface DefaultHandler
- Parameters:
prefix
- The Namespace prefix being declared.uri
- The Namespace URI mapped to the prefix.
- Throws:
SAXException
- Any SAX exception, possibly wrapping another exception.
public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName)
Receive notification of an unparsed entity declaration.
- Specified by:
- unparsedEntityDecl in interface DTDHandler
- Overrides:
- unparsedEntityDecl in interface DefaultHandler
- Parameters:
name
- The entity name.publicId
- The entity public identifier, or null if not available.systemId
- The entity system identifier.notationName
- The name of the associated notation.
public void warn(String msg, args[] ) throws SAXException
Warn the user of an problem.
- Parameters:
msg
- An key into theXSLTErrorResources
table, that is one of the WG_ prefixed definitions.
- Throws:
SAXException
- that wraps aTransformerException
if the currentErrorListener.warning(TransformerException)
method chooses to flag this condition as an error.
public void warning(SAXParseException e) throws SAXException
Receive notification of a XSLT processing warning.
- Specified by:
- warning in interface ErrorHandler
- Overrides:
- warning in interface DefaultHandler
- Parameters:
e
- The warning information encoded as an exception.
- Throws:
SAXException
- that wraps aTransformerException
if the currentErrorListener.warning(TransformerException)
method chooses to flag this condition as an error.