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

## weblogic.apache.xalan.processor
Class StylesheetHandler

    java.lang.Object
      |
      +--org.xml.sax.helpers.DefaultHandler
            |
            +--weblogic.apache.xalan.processor.StylesheetHandler

public class StylesheetHandler
extends org.xml.sax.helpers.DefaultHandler
implements javax.xml.transform.sax.TemplatesHandler, PrefixResolver, NodeConsumer

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.

This class is based on an implementation from the Apache XML Project. In future releases the XML parser, XSLT processor, and associated classes will likely be updated to be based on a later version of the Apache implementations. Since Apache does not guarantee backwards compatibility between versions of their software, we cannot guarantee backwards compatibility of any of the classes contained in the weblogic.apache package or sub-packages.

Constructor Summary
`StylesheetHandler(TransformerFactoryImpl processor)` Create a StylesheetHandler object, creating a root stylesheet as the target.

Method Summary
`void` | `characters(char[] ch, int start, int length)` Receive notification of character data inside an element.
`XPath` | `createXPath(java.lang.String str)` Process an expression string into an XPath.
`void` | `endDocument()` Receive notification of the end of the document.
`void` | `endElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName)` Receive notification of the end of an element.
`void` | `endPrefixMapping(java.lang.String prefix)` Receive notification of the end of a Namespace mapping.
`protected void` | `error(int msg, java.lang.Object[] args, java.lang.Exception e)` Tell the user of an error, and probably throw an exception.
`void` | `error(org.xml.sax.SAXParseException e)` Receive notification of a recoverable XSLT processing error.
`protected void` | `error(java.lang.String msg, java.lang.Exception e)` Tell the user of an error, and probably throw an exception.
`void` | `fatalError(org.xml.sax.SAXParseException e)` Report a fatal XSLT processing error.
`java.lang.String` | `getBaseIdentifier()` Return the base identifier.
`SAXSourceLocator` | `getLocator()` Get the current stylesheet Locator object.
`java.lang.String` | `getNamespaceForPrefix(java.lang.String prefix)` Given a namespace, get the corrisponding prefix from the current namespace support context.
`java.lang.String` | `getNamespaceForPrefix(java.lang.String prefix, org.w3c.dom.Node context)` Given a namespace, get the corrisponding prefix.
`org.w3c.dom.Node` | `getOriginatingNode()` Set the node that is originating the SAX event.
`StylesheetRoot` | `getStylesheetRoot()` Return the stylesheet root that this handler is constructing.
`java.lang.String` | `getSystemId()` Get the base ID (URI or system ID) from where relative URLs will be resolved.
`javax.xml.transform.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.
`void` | `ignorableWhitespace(char[] ch, int start, int length)` Receive notification of ignorable whitespace in element content.
`boolean` | `isStylesheetParsingComplete()` Test whether the _last_ endDocument() has been processed.
`void` | `notationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)` Receive notification of a notation declaration.
`void` | `processingInstruction(java.lang.String target, java.lang.String data)` Receive notification of a processing instruction.
`void` | `pushStylesheet(Stylesheet s)` Push the current stylesheet being constructed.
`org.xml.sax.InputSource` | `resolveEntity(java.lang.String publicId, java.lang.String systemId)` Resolve an external entity.
`void` | `setDocumentLocator(org.xml.sax.Locator locator)` Receive a Locator object for document events.
`void` | `setOriginatingNode(org.w3c.dom.Node n)` Set the node that is originating the SAX event.
`void` | `setSystemId(java.lang.String baseID)` Set the base ID (URL or system ID) for the stylesheet created by this builder.
`void` | `skippedEntity(java.lang.String name)` Receive notification of a skipped entity.
`void` | `startDocument()` Receive notification of the beginning of the document.
`void` | `startElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName, org.xml.sax.Attributes attributes)` Receive notification of the start of an element.
`void` | `startPrefixMapping(java.lang.String prefix, java.lang.String uri)` 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)` Receive notification of an unparsed entity declaration.
`void` | `warn(int msg, java.lang.Object[] args)` Warn the user of an problem.
`void` | `warning(org.xml.sax.SAXParseException e)` Receive notification of a XSLT processing warning.

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

Constructor Detail

### StylesheetHandler

    public StylesheetHandler(TransformerFactoryImpl processor)
                      throws javax.xml.transform.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:
    javax.xml.transform.TransformerConfigurationException - if a StylesheetRoot can not be constructed for some reason.

Method Detail

### createXPath

    public XPath createXPath(java.lang.String str)
                      throws javax.xml.transform.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:
    javax.xml.transform.TransformerException - if the expression can not be processed.
  See Also:
    Section 4 Expressions in XSLT Specification

### getNamespaceForPrefix

    public java.lang.String getNamespaceForPrefix(java.lang.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.

### getNamespaceForPrefix

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

  Given a namespace, get the corrisponding prefix. This is here only to support the `PrefixResolver` 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.

### getTemplates

    public javax.xml.transform.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 javax.xml.transform.sax.TemplatesHandler

  Returns:
    The stylesheet object that was created during the SAX event process, or null if no stylesheet has been created.

### setSystemId

    public void setSystemId(java.lang.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 javax.xml.transform.sax.TemplatesHandler

  Parameters:
    `baseID` - Base URL for this stylesheet.

### getSystemId

    public java.lang.String getSystemId()

  Get the base ID (URI or system ID) from where relative URLs will be resolved.
  Specified by:
    getSystemId in interface javax.xml.transform.sax.TemplatesHandler

  Returns:
    The systemID that was set with `setSystemId(java.lang.String)`.

### resolveEntity

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

  Resolve an external entity.

  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:
    org.xml.sax.SAXException - if the entity can not be resolved.
  Overrides:
    resolveEntity in class org.xml.sax.helpers.DefaultHandler

### notationDecl

    public void notationDecl(java.lang.String name,
                             java.lang.String publicId,
                             java.lang.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.

  Parameters:
    `name` - The notation name.
    `publicId` - The notation public identifier, or null if not available.
    `systemId` - The notation system identifier.
  Overrides:
    notationDecl in class org.xml.sax.helpers.DefaultHandler
  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)

  Receive notification of an unparsed entity declaration.

  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.
  Overrides:
    unparsedEntityDecl in class org.xml.sax.helpers.DefaultHandler
  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)

  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.

  Parameters:
    `locator` - A locator for all SAX document events.
  Overrides:
    setDocumentLocator in class org.xml.sax.helpers.DefaultHandler
  See Also:
    `ContentHandler.setDocumentLocator(org.xml.sax.Locator)`, `Locator`

### startDocument

    public void startDocument()
                       throws org.xml.sax.SAXException

  Receive notification of the beginning of the document.

  Throws:
    org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
  Overrides:
    startDocument in class org.xml.sax.helpers.DefaultHandler
  See Also:
    `ContentHandler.startDocument()`

### isStylesheetParsingComplete

    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.

### endDocument

    public void endDocument()
                     throws org.xml.sax.SAXException

  Receive notification of the end of the document.

  Throws:
    org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
  Overrides:
    endDocument in class org.xml.sax.helpers.DefaultHandler
  See Also:
    `ContentHandler.endDocument()`

### startPrefixMapping

    public void startPrefixMapping(java.lang.String prefix,
                                   java.lang.String uri)
                            throws org.xml.sax.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).

  Parameters:
    `prefix` - The Namespace prefix being declared.
    `uri` - The Namespace URI mapped to the prefix.
  Throws:
    org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
  Overrides:
    startPrefixMapping in class org.xml.sax.helpers.DefaultHandler
  See Also:
    `ContentHandler.startPrefixMapping(java.lang.String, java.lang.String)`

### endPrefixMapping

    public void endPrefixMapping(java.lang.String prefix)
                          throws org.xml.sax.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).

  Parameters:
    `prefix` - The Namespace prefix being declared.
  Throws:
    org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
  Overrides:
    endPrefixMapping in class org.xml.sax.helpers.DefaultHandler
  See Also:
    `ContentHandler.endPrefixMapping(java.lang.String)`

### startElement

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

  Receive notification of the start of an element.

  Parameters:
    `name` - The element type name.
    `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:
    org.xml.sax.SAXException -
  Overrides:
    startElement in class org.xml.sax.helpers.DefaultHandler

### endElement

    public void endElement(java.lang.String uri,
                           java.lang.String localName,
                           java.lang.String rawName)
                    throws org.xml.sax.SAXException

  Receive notification of the end of an element.

  Parameters:
    `name` - The element type name.
    `attributes` - The specified or defaulted attributes.
    `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:
    org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
  Overrides:
    endElement in class org.xml.sax.helpers.DefaultHandler
  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.SAXException

  Receive notification of character data inside an element.

  Parameters:
    `ch` - The characters.
    `start` - The start position in the character array.
    `length` - The number of characters to use from the character array.
  Throws:
    org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
  Overrides:
    characters in class org.xml.sax.helpers.DefaultHandler
  See Also:
    `ContentHandler.characters(char[], int, int)`

### ignorableWhitespace

    public void ignorableWhitespace(char[] ch,
                                    int start,
                                    int length)
                             throws org.xml.sax.SAXException

  Receive notification of ignorable whitespace in element content.

  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:
    org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
  Overrides:
    ignorableWhitespace in class org.xml.sax.helpers.DefaultHandler
  See Also:
    `ContentHandler.ignorableWhitespace(char[], int, int)`

### processingInstruction

    public void processingInstruction(java.lang.String target,
                                      java.lang.String data)
                               throws org.xml.sax.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.

  Parameters:
    `target` - The processing instruction target.
    `data` - The processing instruction data, or null if none is supplied.
  Throws:
    org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
  Overrides:
    processingInstruction in class org.xml.sax.helpers.DefaultHandler
  See Also:
    `ContentHandler.processingInstruction(java.lang.String, java.lang.String)`

### skippedEntity

    public void skippedEntity(java.lang.String name)
                       throws org.xml.sax.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.

  Parameters:
    `name` - The name of the skipped entity.
  Throws:
    org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
  Overrides:
    skippedEntity in class org.xml.sax.helpers.DefaultHandler
  See Also:
    `ContentHandler.processingInstruction(java.lang.String, java.lang.String)`

### warn

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

  Warn the user of an problem.

  Parameters:
    `msg` - An index into the `XSLTErrorResources` table, that is one of the WG_ prefixed definitions.
    `args` - An array of arguments for the given warning.
  Throws:
    org.xml.sax.SAXException - that wraps a `TransformerException` if the current `ErrorListener.warning(javax.xml.transform.TransformerException)` method chooses to flag this condition as an error.

### error

    protected void error(java.lang.String msg,
                         java.lang.Exception e)
                  throws org.xml.sax.SAXException

  Tell the user of an error, and probably throw an exception.

  Parameters:
    `msg` - An error message.
    `e` - An error which the SAXException should wrap.
  Throws:
    org.xml.sax.SAXException - that wraps a `TransformerException` if the current `ErrorListener.error(javax.xml.transform.TransformerException)` method chooses to flag this condition as an error.

### error

    protected void error(int msg,
                         java.lang.Object[] args,
                         java.lang.Exception e)
                  throws org.xml.sax.SAXException

  Tell the user of an error, and probably throw an exception.

  Parameters:
    `msg` - An index into the `XSLTErrorResources` table, that is one of the WG_ prefixed definitions.
    `args` - An array of arguments for the given warning.
    `e` - An error which the SAXException should wrap.
  Throws:
    org.xml.sax.SAXException - that wraps a `TransformerException` if the current `ErrorListener.error(javax.xml.transform.TransformerException)` method chooses to flag this condition as an error.

### warning

    public void warning(org.xml.sax.SAXParseException e)
                 throws org.xml.sax.SAXException

  Receive notification of a XSLT processing warning.

  Parameters:
    `e` - The warning information encoded as an exception.
  Throws:
    org.xml.sax.SAXException - that wraps a `TransformerException` if the current `ErrorListener.warning(javax.xml.transform.TransformerException)` method chooses to flag this condition as an error.
  Overrides:
    warning in class org.xml.sax.helpers.DefaultHandler

### error

    public void error(org.xml.sax.SAXParseException e)
               throws org.xml.sax.SAXException

  Receive notification of a recoverable XSLT processing error.

  Parameters:
    `e` - The error information encoded as an exception.
  Throws:
    org.xml.sax.SAXException - that wraps a `TransformerException` if the current `ErrorListener.error(javax.xml.transform.TransformerException)` method chooses to flag this condition as an error.
  Overrides:
    error in class org.xml.sax.helpers.DefaultHandler

### fatalError

    public void fatalError(org.xml.sax.SAXParseException e)
                    throws org.xml.sax.SAXException

  Report a fatal XSLT processing error.

  Parameters:
    `e` - The error information encoded as an exception.
  Throws:
    org.xml.sax.SAXException - that wraps a `TransformerException` if the current `ErrorListener.fatalError(javax.xml.transform.TransformerException)` method chooses to flag this condition as an error.
  Overrides:
    fatalError in class org.xml.sax.helpers.DefaultHandler

### getStylesheetRoot

    public StylesheetRoot getStylesheetRoot()

  Return the stylesheet root that this handler is constructing.

  Returns:
    The root stylesheet of the stylesheets tree.

### pushStylesheet

    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.

### getBaseIdentifier

    public java.lang.String getBaseIdentifier()

  Return the base identifier.
  Specified by:
    getBaseIdentifier in interface PrefixResolver

  Returns:
    The base identifier of the current stylesheet.

### getLocator

    public SAXSourceLocator getLocator()

  Get the current stylesheet Locator object.

  Returns:
    non-null reference to the current locator object.

### setOriginatingNode

    public void setOriginatingNode(org.w3c.dom.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`

### getOriginatingNode

    public org.w3c.dom.Node getOriginatingNode()

  Set the node that is originating the SAX event.

  Returns:
    Reference to node that originated the current event.
  See Also:
    `NodeConsumer`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Documentation is available at http://e-docs.bea.com/wls/docs70
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004 BEA Systems, Inc. All Rights Reserved.
WebLogic Server 7.0 API Reference