APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.xml.internal.utils

public Class StylesheetPIHandler

extends DefaultHandler
Class Inheritance
Imports
java.util.ArrayList, .List, .StringTokenizer, javax.xml.transform.Source, .TransformerException, .URIResolver, javax.xml.transform.sax.SAXSource, org.xml.sax.Attributes, .InputSource, 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

Modifier and TypeField and Description
pack-priv String
m_baseID

The baseID of the document being processed.

pack-priv String
m_charset

The desired character set criteria.

pack-priv String
m_media

The desired media criteria.

pack-priv List<Source>
m_stylesheets

A list of SAXSource objects that match the criteria.

pack-priv String
m_title

The desired title criteria.

pack-priv URIResolver
m_uriResolver

The object that implements the URIResolver interface, or null.

Constructor Summary

AccessConstructor and Description
public
StylesheetPIHandler(String
The base ID of the XML document, needed to resolve relative IDs.
baseID
,
String
The desired media criteria.
media
,
String
The desired title criteria.
title
,
String
The desired character set criteria.
charset
)

Construct a StylesheetPIHandler instance that will search for xml-stylesheet PIs based on the given criteria.

Method Summary

Modifier and TypeMethod and Description
public Source

Returns:

Source object that references the last stylesheet reference that matches the constraints.
getAssociatedStylesheet
()

Return the last stylesheet found that match the constraints.

public String
public URIResolver

Returns:

The URIResolver that was set with setURIResolver.
getURIResolver
()

Get the object that will be used to resolve URIs in href in xml-stylesheet processing instruction.

public void
processingInstruction(String
The processing instruction target.
target
,
String
The processing instruction data, or null if none is supplied.
data
)

Overrides org.xml.sax.helpers.DefaultHandler.processingInstruction.

Implements org.xml.sax.ContentHandler.processingInstruction.

Handle the xml-stylesheet processing instruction.

public void
setBaseId(String baseId)

Added additional getter and setter methods for the Base Id to fix bugzilla bug 24187

public void
setURIResolver(URIResolver
An object that implements the URIResolver interface, or null.
resolver
)

Get the object that will be used to resolve URIs in href in xml-stylesheet processing instruction.

public void
startElement(String
The Namespace URI, or an empty string.
namespaceURI
,
String
The local name (without prefix), or empty string if not namespace processing.
localName
,
String
The qualified name (with prefix).
qName
,
Attributes
The specified or defaulted attributes.
atts
)

Overrides org.xml.sax.helpers.DefaultHandler.startElement.

Implements org.xml.sax.ContentHandler.startElement.

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.

Inherited from org.xml.sax.helpers.DefaultHandler:
charactersendDocumentendElementendPrefixMappingerrorfatalErrorignorableWhitespacenotationDeclresolveEntitysetDocumentLocatorskippedEntitystartDocumentstartPrefixMappingunparsedEntityDeclwarning

Field Detail

m_baseIDback to summary
pack-priv String m_baseID

The baseID of the document being processed.

m_charsetback to summary
pack-priv String m_charset

The desired character set criteria.

m_mediaback to summary
pack-priv String m_media

The desired media criteria.

m_stylesheetsback to summary
pack-priv List<Source> m_stylesheets

A list of SAXSource objects that match the criteria.

m_titleback to summary
pack-priv String m_title

The desired title criteria.

m_uriResolverback to summary
pack-priv URIResolver m_uriResolver

The object that implements the URIResolver interface, or null.

Constructor Detail

StylesheetPIHandlerback to summary
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:String

The base ID of the XML document, needed to resolve relative IDs.

media:String

The desired media criteria.

title:String

The desired title criteria.

charset:String

The desired character set criteria.

Method Detail

getAssociatedStylesheetback to summary
public Source getAssociatedStylesheet()

Return the last stylesheet found that match the constraints.

Returns:Source

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

getBaseIdback to summary
public String getBaseId()
getURIResolverback to summary
public URIResolver getURIResolver()

Get the object that will be used to resolve URIs in href in xml-stylesheet processing instruction.

Returns:URIResolver

The URIResolver that was set with setURIResolver.

processingInstructionback to summary
public void processingInstruction(String target, String data) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.processingInstruction.

Implements org.xml.sax.ContentHandler.processingInstruction.

Handle the xml-stylesheet processing instruction.

Parameters
target:String

The processing instruction target.

data:String

The processing instruction data, or null if none is supplied.

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
See Also
org.xml.sax.ContentHandler#processingInstruction, Associating Style Sheets with XML documents, Version 1.0
setBaseIdback to summary
public void setBaseId(String baseId)

Added additional getter and setter methods for the Base Id to fix bugzilla bug 24187

setURIResolverback to summary
public void setURIResolver(URIResolver resolver)

Get the object that will be used to resolve URIs in href in xml-stylesheet processing instruction.

Parameters
resolver:URIResolver

An object that implements the URIResolver interface, or null.

startElementback to summary
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.startElement.

Implements org.xml.sax.ContentHandler.startElement.

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
namespaceURI:String

The Namespace URI, or an empty string.

localName:String

The local name (without prefix), or empty string if not namespace processing.

qName:String

The qualified name (with prefix).

atts:Attributes

The specified or defaulted attributes.

Exceptions
SAXException:

Doc from org.xml.sax.helpers.DefaultHandler.startElement.

Any SAX exception, possibly wrapping another exception.

StopParseException:
since there can be no valid xml-stylesheet processing instructions past the first element.