org.apache.xalan.processor
Class StylesheetPIHandler

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byorg.apache.xalan.processor.StylesheetPIHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class StylesheetPIHandler
extends org.xml.sax.helpers.DefaultHandler

Search for the xml-stylesheet processing instructions in an XML document.

See Also:
Associating Style Sheets with XML documents, Version 1.0

Field Summary
(package private)  String m_baseID
          The baseID of the document being processed.
(package private)  String m_charset
          The desired character set criteria.
(package private)  String m_media
          The desired media criteria.
(package private)  Vector m_stylesheets
          A list of SAXSource objects that match the criteria.
(package private)  String m_title
          The desired title criteria.
(package private)  javax.xml.transform.URIResolver m_uriResolver
          The object that implements the URIResolver interface, or null.
 
Constructor Summary
StylesheetPIHandler(String baseID, String media, String title, String charset)
          Construct a StylesheetPIHandler instance that will search for xml-stylesheet PIs based on the given criteria.
 
Method Summary
 javax.xml.transform.Source getAssociatedStylesheet()
          Return the last stylesheet found that match the constraints.
 javax.xml.transform.URIResolver getURIResolver()
          Get the object that will be used to resolve URIs in href in xml-stylesheet processing instruction.
 void processingInstruction(String target, String data)
          Handle the xml-stylesheet processing instruction.
 void setURIResolver(javax.xml.transform.URIResolver resolver)
          Get the object that will be used to resolve URIs in href in xml-stylesheet processing instruction.
 void startElement(String namespaceURI, String localName, String qName, org.xml.sax.Attributes atts)
          The spec notes that "The xml-stylesheet processing instruction is allowed only in the prolog of an XML document
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_baseID

String m_baseID
The baseID of the document being processed.


m_media

String m_media
The desired media criteria.


m_title

String m_title
The desired title criteria.


m_charset

String m_charset
The desired character set criteria.


m_stylesheets

Vector m_stylesheets
A list of SAXSource objects that match the criteria.


m_uriResolver

javax.xml.transform.URIResolver m_uriResolver
The object that implements the URIResolver interface, or null.

Constructor Detail

StylesheetPIHandler

public StylesheetPIHandler(String baseID,
                           String media,
                           String title,
                           String charset)
Construct a StylesheetPIHandler instance that will search for xml-stylesheet PIs based on the given criteria.

Parameters:
baseID - The base ID of the XML document, needed to resolve relative IDs.
media - The desired media criteria.
title - The desired title criteria.
charset - The desired character set criteria.
Method Detail

setURIResolver

public void setURIResolver(javax.xml.transform.URIResolver resolver)
Get the object that will be used to resolve URIs in href in xml-stylesheet processing instruction.

Parameters:
resolver - An object that implements the URIResolver interface, or null.

getURIResolver

public javax.xml.transform.URIResolver getURIResolver()
Get the object that will be used to resolve URIs in href in xml-stylesheet processing instruction.

Returns:
The URIResolver that was set with setURIResolver.

getAssociatedStylesheet

public javax.xml.transform.Source getAssociatedStylesheet()
Return the last stylesheet found that match the constraints.

Returns:
Source object that references the last stylesheet reference that matches the constraints.

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws org.xml.sax.SAXException
Handle the xml-stylesheet processing instruction.

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.
See Also:
ContentHandler.processingInstruction(java.lang.String, java.lang.String), Associating Style Sheets with XML documents, Version 1.0

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
The spec notes that "The xml-stylesheet processing instruction is allowed only in the prolog of an XML document.", so, at least for right now, I'm going to go ahead an throw a TransformerException in order to stop the parse.

Parameters:
localName - The local name (without prefix), or empty string if not namespace processing.
Throws:
StopParseException - since there can be no valid xml-stylesheet processing instructions past the first element.
org.xml.sax.SAXException