Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.xalan.processor
Class StylesheetHandler

    java.lang.Object
      |
      +--org.apache.xalan.processor.StylesheetHandler

Direct Known Subclasses:
  CompilingStylesheetHandler

public class StylesheetHandler
extends java.lang.Object
implements EntityResolver, DTDHandler, ContentHandler, ErrorHandler, TemplatesBuilder, PrefixResolver, NodeConsumer

**For advanced use only** Initializes and processes a stylesheet via SAX events. This class acts as essentially a state machine, maintaining a ContentHandler stack, and pushing appropriate content handlers as parse events occur.

Constructor Summary
`StylesheetHandler(StylesheetProcessor processor)` **For advanced use only** Create a StylesheetHandler object, creating a root stylesheet as the target.

Method Summary
`void` | `characters(char[] ch, int start, int length)` **For advanced use only** Receive notification of character data inside an element.
`XPath` | `createXPath(java.lang.String str)` **For advanced use only** Process an expression string into an XPath.
`void` | `endDocument()` **For advanced use only** Receive notification of the end of the document.
`void` | `endElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName)` **For advanced use only** Receive notification of the end of an element.
`void` | `endPrefixMapping(java.lang.String prefix)` **For advanced use only** Receive notification of the end of a Namespace mapping.
`void` | `error(SAXParseException e)` **For advanced use only** Receive notification of a recoverable parser error.
`void` | `fatalError(SAXParseException e)` **For advanced use only** Report a fatal XML parsing error.
`java.lang.String` | `getBaseIdentifier()` **For advanced use only** Return the base identifier.
`Locator` | `getLocator()` **For advanced use only** Get the current stylesheet Locator object.
`java.lang.String` | `getNamespaceForPrefix(java.lang.String prefix)` **For advanced use only** Given a namespace, get the corrisponding prefix.
`java.lang.String` | `getNamespaceForPrefix(java.lang.String prefix, Node context)` **For advanced use only** Given a namespace, get the corrisponding prefix.
`Node` | `getOriginatingNode()` **For advanced use only** Set the node that is originating the SAX event.
`StylesheetRoot` | `getStylesheetRoot()` **For advanced use only** Return the stylesheet that this handler is constructing.
`Templates` | `getTemplates()` **For advanced use only** 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.
`void` | `ignorableWhitespace(char[] ch, int start, int length)` **For advanced use only** Receive notification of ignorable whitespace in element content.
`void` | `notationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)` **For advanced use only** Receive notification of a notation declaration.
`void` | `processingInstruction(java.lang.String target, java.lang.String data)` **For advanced use only** Receive notification of a processing instruction.
`InputSource` | `resolveEntity(java.lang.String publicId, java.lang.String systemId)` **For advanced use only** Resolve an external entity.
`void` | `setBaseID(java.lang.String baseID)` **For advanced use only** Set the base ID (URL or system ID) for the stylesheet created by this builder.
`void` | `setDocumentLocator(Locator locator)` **For advanced use only** Receive a Locator object for document events.
`void` | `setOriginatingNode(Node n)` **For advanced use only** Set the node that is originating the SAX event.
`void` | `skippedEntity(java.lang.String name)` **For advanced use only** Receive notification of a skipped entity.
`void` | `startDocument()` **For advanced use only** Receive notification of the beginning of the document.
`void` | `startElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName, Attributes attributes)` **For advanced use only** Receive notification of the start of an element.
`void` | `startPrefixMapping(java.lang.String prefix, java.lang.String uri)` **For advanced use only** Receive notification of the start of a Namespace mapping.
`void` | `unparsedEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notationName)` **For advanced use only** Receive notification of an unparsed entity declaration.
`void` | `warn(int msg, java.lang.Object[] args)` **For internal use only** Warn the user of an problem.
`void` | `warning(SAXParseException e)` **For advanced use only** Receive notification of a parser warning.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### StylesheetHandler

    public StylesheetHandler(StylesheetProcessor processor)
                      throws ProcessorException

  **For advanced use only** Create a StylesheetHandler object, creating a root stylesheet as the target.
  Throws:
    May - throw ProcessorException if a StylesheetRoot can not be constructed for some reason.

Method Detail

### createXPath

    public XPath createXPath(java.lang.String str)
                      throws SAXException

  **For advanced use only** Process an expression string into an XPath. Must be public for access by the AVT class.

### getNamespaceForPrefix

    public java.lang.String getNamespaceForPrefix(java.lang.String prefix)

  **For advanced use only** Given a namespace, get the corrisponding prefix. This assumes that the PrevixResolver hold's it's own namespace context, or is a namespace context itself.
  Specified by:
    getNamespaceForPrefix in interface PrefixResolver

### getNamespaceForPrefix

    public java.lang.String getNamespaceForPrefix(java.lang.String prefix,
                                                  Node context)

  **For advanced use only** Given a namespace, get the corrisponding prefix.
  Specified by:
    getNamespaceForPrefix in interface PrefixResolver

### getBaseIdentifier

    public java.lang.String getBaseIdentifier()

  **For advanced use only** Return the base identifier.
  Specified by:
    getBaseIdentifier in interface PrefixResolver

### getTemplates

    public Templates getTemplates()
                           throws TransformException

  **For advanced use only** 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 TemplatesBuilder
  Returns:
    The stylesheet object that was created during the SAX event process, or null if no stylesheet has been created.

### setBaseID

    public void setBaseID(java.lang.String baseID)

  **For advanced use only** 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:
    setBaseID in interface TemplatesBuilder
  Parameters:
    `baseID` - Base URL for this stylesheet.

### resolveEntity

    public InputSource resolveEntity(java.lang.String publicId,
                                     java.lang.String systemId)
                              throws SAXException

  **For advanced use only** Resolve an external entity.

  Always return null, so that the parser will use the system identifier provided in the XML document. This method implements the SAX default behaviour: application writers can override it in a subclass to do special translations such as catalog lookups or URI redirection.

  Specified by:
    resolveEntity in interface EntityResolver
  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 - Any SAX exception, possibly wrapping another exception.
  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)

  **For advanced use only** 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
  Parameters:
    `name` - The notation name.
    `publicId` - The notation public identifier, or null if not available.
    `systemId` - The notation system identifier.
  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)

  **For advanced use only** Receive notification of an unparsed entity declaration.
  Specified by:
    unparsedEntityDecl in interface DTDHandler
  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.
  See Also:
    `DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)`

### setDocumentLocator

    public void setDocumentLocator(Locator locator)

  **For advanced use only** 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 stylesheed has been parsed. We pop in in popStylesheet.
  Specified by:
    setDocumentLocator in interface ContentHandler
  Parameters:
    `locator` - A locator for all SAX document events.
  See Also:
    `ContentHandler.setDocumentLocator(org.xml.sax.Locator)`, `Locator`

### startDocument

    public void startDocument()
                       throws SAXException

  **For advanced use only** Receive notification of the beginning of the document.
  Specified by:
    startDocument in interface ContentHandler
  Throws:
    SAXException - Any SAX exception, possibly wrapping another exception.
  See Also:
    `ContentHandler.startDocument()`

### endDocument

    public void endDocument()
                     throws SAXException

  **For advanced use only** Receive notification of the end of the document.
  Specified by:
    endDocument in interface ContentHandler
  Throws:
    SAXException - Any SAX exception, possibly wrapping another exception.
  See Also:
    `ContentHandler.endDocument()`

### startPrefixMapping

    public void startPrefixMapping(java.lang.String prefix,
                                   java.lang.String uri)
                            throws SAXException

  **For advanced use only** 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
  Parameters:
    `prefix` - The Namespace prefix being declared.
    `uri` - The Namespace URI mapped to the prefix.
  Throws:
    SAXException - Any SAX exception, possibly wrapping another exception.
  See Also:
    `ContentHandler.startPrefixMapping(java.lang.String, java.lang.String)`

### endPrefixMapping

    public void endPrefixMapping(java.lang.String prefix)
                          throws SAXException

  **For advanced use only** 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
  Parameters:
    `prefix` - The Namespace prefix being declared.
  Throws:
    SAXException - Any SAX exception, possibly wrapping another exception.
  See Also:
    `ContentHandler.endPrefixMapping(java.lang.String)`

### startElement

    public void startElement(java.lang.String uri,
                             java.lang.String localName,
                             java.lang.String rawName,
                             Attributes attributes)
                      throws SAXException

  **For advanced use only** Receive notification of the start of an element.
  Specified by:
    startElement in interface ContentHandler
  Parameters:
    `name` - The element type name.
    `attributes` - The specified or defaulted attributes.
  Throws:
    SAXException - Any SAX exception, possibly wrapping another exception.
  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 rawName)
                    throws SAXException

  **For advanced use only** Receive notification of the end of an element.
  Specified by:
    endElement in interface ContentHandler
  Parameters:
    `name` - The element type name.
    `attributes` - The specified or defaulted attributes.
  Throws:
    SAXException - Any SAX exception, possibly wrapping another exception.
  See Also:
    `ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)`

### characters

    public void characters(char[] ch,
                           int start,
                           int length)
                    throws SAXException

  **For advanced use only** Receive notification of character data inside an element.
  Specified by:
    characters in interface ContentHandler
  Parameters:
    `ch` - The characters.
    `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.
  See Also:
    `ContentHandler.characters(char[], int, int)`

### ignorableWhitespace

    public void ignorableWhitespace(char[] ch,
                                    int start,
                                    int length)
                             throws SAXException

  **For advanced use only** Receive notification of ignorable whitespace in element content.
  Specified by:
    ignorableWhitespace in interface ContentHandler
  Parameters:
    `ch` - The whitespace characters.
    `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.
  See Also:
    `ContentHandler.ignorableWhitespace(char[], int, int)`

### processingInstruction

    public void processingInstruction(java.lang.String target,
                                      java.lang.String data)
                               throws SAXException

  **For advanced use only** Receive notification of a processing instruction.

  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
  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.
  See Also:
    `ContentHandler.processingInstruction(java.lang.String, java.lang.String)`

### skippedEntity

    public void skippedEntity(java.lang.String name)
                       throws SAXException

  **For advanced use only** 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
  Parameters:
    `name` - The name of the skipped entity.
  Throws:
    SAXException - Any SAX exception, possibly wrapping another exception.
  See Also:
    `ContentHandler.processingInstruction(java.lang.String, java.lang.String)`

### warn

    public void warn(int msg,
                     java.lang.Object[] args)
              throws SAXException

  **For internal use only** Warn the user of an problem.
  Throws:
    XSLProcessorException - thrown if the active ProblemListener and XPathContext decide the error condition is severe enough to halt processing.

### warning

    public void warning(SAXParseException e)
                 throws SAXException

  **For advanced use only** Receive notification of a parser warning.
  Specified by:
    warning in interface ErrorHandler
  Parameters:
    `e` - The warning information encoded as an exception.
  Throws:
    SAXException - Any SAX exception, possibly wrapping another exception.
  See Also:
    `ErrorHandler.warning(org.xml.sax.SAXParseException)`, `SAXParseException`

### error

    public void error(SAXParseException e)
               throws SAXException

  **For advanced use only** Receive notification of a recoverable parser error.
  Specified by:
    error in interface ErrorHandler
  Parameters:
    `e` - The warning information encoded as an exception.
  Throws:
    SAXException - Any SAX exception, possibly wrapping another exception.
  See Also:
    `ErrorHandler.warning(org.xml.sax.SAXParseException)`, `SAXParseException`

### fatalError

    public void fatalError(SAXParseException e)
                    throws SAXException

  **For advanced use only** Report a fatal XML parsing error.

  The default implementation throws a SAXParseException. Application writers may override this method in a subclass if they need to take specific actions for each fatal error (such as collecting all of the errors into a single report): in any case, the application must stop all regular processing when this method is invoked, since the document is no longer reliable, and the parser may no longer report parsing events.

  Specified by:
    fatalError in interface ErrorHandler
  Parameters:
    `e` - The error information encoded as an exception.
  Throws:
    SAXException - Any SAX exception, possibly wrapping another exception.
  See Also:
    `ErrorHandler.fatalError(org.xml.sax.SAXParseException)`, `SAXParseException`

### getStylesheetRoot

    public StylesheetRoot getStylesheetRoot()

  **For advanced use only** Return the stylesheet that this handler is constructing.

### getLocator

    public Locator getLocator()

  **For advanced use only** Get the current stylesheet Locator object.

### setOriginatingNode

    public void setOriginatingNode(Node n)

  **For advanced use only** Set the node that is originating the SAX event.
  Specified by:
    setOriginatingNode in interface NodeConsumer

### getOriginatingNode

    public Node getOriginatingNode()

  **For advanced use only** Set the node that is originating the SAX event.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000 Apache XML Project. All Rights Reserved.