org.apache.xerces.xpointer

Class XPointerHandler

Implemented Interfaces:
org.apache.xerces.xni.parser.XMLComponent, org.apache.xerces.xni.parser.XMLDocumentFilter, org.apache.xerces.xni.parser.XMLDTDFilter, XPointerProcessor

public final class XPointerHandler
extends XIncludeHandler
implements XPointerProcessor

This is a pipeline component which extends the XIncludeHandler to perform XPointer specific processing specified in the W3C XPointerFramework and element() Scheme Recommendations.

This component analyzes each event in the pipeline, looking for an element that matches a PointerPart in the parent XInclude element's xpointer attribute value. If the match succeeds, all children are passed by this component.

See the XPointer Framework Recommendation for more information on the XPointer Framework and ShortHand Pointers. See the XPointer element() Scheme Recommendation for more information on the XPointer element() Scheme.

Version:
$Id: XPointerHandler.java 320580 2005-09-15 17:51:14Z mrglavas $

Nested Class Summary

Nested classes/interfaces inherited from class org.apache.xerces.xinclude.XIncludeHandler

XIncludeHandler.Notation, XIncludeHandler.UnparsedEntity

Field Summary

protected org.apache.xerces.xni.parser.XMLErrorHandler
fErrorHandler
protected boolean
fFixupBase
protected boolean
fFixupLang
protected boolean
fFoundMatchingPtrPart
protected boolean
fIsXPointerResolved
protected SymbolTable
fSymbolTable
protected XMLErrorReporter
fXPointerErrorReporter
protected XPointerPart
fXPointerPart
protected Vector
fXPointerParts

Fields inherited from class org.apache.xerces.xinclude.XIncludeHandler

ALLOW_UE_AND_NOTATION_EVENTS, BUFFER_SIZE, CURRENT_BASE_URI, DYNAMIC_VALIDATION, ENTITY_RESOLVER, ERROR_REPORTER, HTTP_ACCEPT, HTTP_ACCEPT_LANGUAGE, PARSER_SETTINGS, SCHEMA_VALIDATION, SECURITY_MANAGER, SYMBOL_TABLE, VALIDATION, XINCLUDE_ATTR_ACCEPT, XINCLUDE_ATTR_ACCEPT_LANGUAGE, XINCLUDE_ATTR_ENCODING, XINCLUDE_ATTR_HREF, XINCLUDE_ATTR_PARSE, XINCLUDE_DEFAULT_CONFIGURATION, XINCLUDE_FALLBACK, XINCLUDE_FIXUP_BASE_URIS, XINCLUDE_FIXUP_LANGUAGE, XINCLUDE_INCLUDE, XINCLUDE_INCLUDED, XINCLUDE_NS_URI, XINCLUDE_PARSE_TEXT, XINCLUDE_PARSE_XML, XPOINTER, fBaseURI, fBaseURIScope, fBufferSize, fChildConfig, fCurrentBaseURI, fCurrentLanguage, fDTDHandler, fDTDSource, fDocLocation, fDocumentHandler, fDocumentSource, fEntityResolver, fErrorReporter, fExpandedSystemID, fHrefFromParent, fLanguageScope, fLanguageStack, fLiteralSystemID, fNamespaceContext, fParentRelativeURI, fParentXIncludeHandler, fSecurityManager, fSettings, fSymbolTable, fXInclude10TextReader, fXInclude11TextReader, fXIncludeChildConfig, fXIncludeMessageFormatter, fXPointerChildConfig, fXPtrProcessor

Fields inherited from interface org.apache.xerces.xpointer.XPointerProcessor

EVENT_ELEMENT_EMPTY, EVENT_ELEMENT_END, EVENT_ELEMENT_START

Constructor Summary

XPointerHandler()
XPointerHandler(SymbolTable symbolTable, org.apache.xerces.xni.parser.XMLErrorHandler errorHandler, XMLErrorReporter errorReporter)

Method Summary

void
characters(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs)
Character content.
void
comment(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs)
If the comment is a child of a matched element, then pass else return.
void
emptyElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes, org.apache.xerces.xni.Augmentations augs)
An empty element.
void
endCDATA(org.apache.xerces.xni.Augmentations augs)
The end of a CDATA section.
void
endElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.Augmentations augs)
The end of an element.
Vector
getPointerParts()
Returns a Vector of XPointerPart objects
XPointerPart
getXPointerPart()
Returns the pointer part used to resolve the document fragment.
void
ignorableWhitespace(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs)
Ignorable whitespace.
protected void
init()
Initializes the XPointer Processor;
protected void
initErrorReporter()
Initializes error handling objects
boolean
isChildFragmentResolved()
Returns true if the XPointer expression resolves to a non-element child of the current resource fragment.
boolean
isFragmentResolved()
Returns true if the Node fragment is resolved.
boolean
isXPointerResolved()
Returns true if the XPointer successfully found a sub-resource .
void
parseXPointer(String xpointer)
Parses the XPointer framework expression and delegates scheme specific parsing.
void
processingInstruction(String target, org.apache.xerces.xni.XMLString data, org.apache.xerces.xni.Augmentations augs)
A processing instruction.
boolean
resolveXPointer(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes, org.apache.xerces.xni.Augmentations augs, int event)
void
setDocumentHandler(org.apache.xerces.xni.XMLDocumentHandler handler)
void
setProperty(String propertyId, Object value)
Sets the value of a property.
void
startCDATA(org.apache.xerces.xni.Augmentations augs)
The start of a CDATA section.
void
startElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes, org.apache.xerces.xni.Augmentations augs)
The start of an element.

Methods inherited from class org.apache.xerces.xinclude.XIncludeHandler

addNotation, addUnparsedEntity, attributeDecl, characters, checkAndSendNotation, checkAndSendUnparsedEntity, checkNotation, checkUnparsedEntity, comment, copyFeatures, copyFeatures, doctypeDecl, elementDecl, emptyElement, endAttlist, endCDATA, endConditional, endDTD, endDocument, endElement, endExternalSubset, endGeneralEntity, endParameterEntity, externalEntityDecl, getBaseURI, getDTDHandler, getDTDSource, getDocumentHandler, getDocumentSource, getFeatureDefault, getLanguage, getPropertyDefault, getRecognizedFeatures, getRecognizedProperties, getRelativeBaseURI, getRelativeURI, getSawFallback, getSawInclude, getState, getState, handleFallbackElement, handleIncludeElement, hasXIncludeNamespace, ignorableWhitespace, ignoredCharacters, internalEntityDecl, isFallbackElement, isIncludeElement, isRootDocument, isTopLevelIncludedItem, isTopLevelIncludedItemViaFallback, isTopLevelIncludedItemViaInclude, modifyAugmentations, modifyAugmentations, notationDecl, processAttributes, processXMLBaseAttributes, processXMLLangAttributes, processingInstruction, reportFatalError, reportFatalError, reportResourceError, reportResourceError, reset, restoreBaseURI, restoreLanguage, sameBaseURIAsIncludeParent, sameLanguageAsIncludeParent, saveBaseURI, saveLanguage, searchForRecursiveIncludes, setDTDHandler, setDTDSource, setDocumentHandler, setDocumentSource, setFeature, setHref, setParent, setProperty, setSawFallback, setSawInclude, setState, setupCurrentBaseURI, startAttlist, startCDATA, startConditional, startDTD, startDocument, startElement, startExternalSubset, startGeneralEntity, startParameterEntity, textDecl, unparsedEntityDecl, xmlDecl

Field Details

fErrorHandler

protected org.apache.xerces.xni.parser.XMLErrorHandler fErrorHandler

fFixupBase

protected boolean fFixupBase

fFixupLang

protected boolean fFixupLang

fFoundMatchingPtrPart

protected boolean fFoundMatchingPtrPart

fIsXPointerResolved

protected boolean fIsXPointerResolved

fSymbolTable

protected SymbolTable fSymbolTable

fXPointerErrorReporter

protected XMLErrorReporter fXPointerErrorReporter

fXPointerPart

protected XPointerPart fXPointerPart

fXPointerParts

protected Vector fXPointerParts

Constructor Details

XPointerHandler

public XPointerHandler()

XPointerHandler

public XPointerHandler(SymbolTable symbolTable,
                       org.apache.xerces.xni.parser.XMLErrorHandler errorHandler,
                       XMLErrorReporter errorReporter)

Method Details

characters

public void characters(org.apache.xerces.xni.XMLString text,
                       org.apache.xerces.xni.Augmentations augs)
            throws org.apache.xerces.xni.XNIException
Character content.
Specified by:
characters in interface org.apache.xerces.xni.XMLDocumentHandler
Overrides:
characters in interface XIncludeHandler
Parameters:
text - The content.
augs - Additional information that may include infoset augmentations
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

comment

public void comment(org.apache.xerces.xni.XMLString text,
                    org.apache.xerces.xni.Augmentations augs)
            throws org.apache.xerces.xni.XNIException
If the comment is a child of a matched element, then pass else return.
Specified by:
comment in interface org.apache.xerces.xni.XMLDocumentHandler
comment in interface org.apache.xerces.xni.XMLDTDHandler
Overrides:
comment in interface XIncludeHandler
Parameters:
text - The text in the comment.
augs - Additional information that may include infoset augmentations
Throws:
org.apache.xerces.xni.XNIException - Thrown by application to signal an error.

emptyElement

public void emptyElement(org.apache.xerces.xni.QName element,
                         org.apache.xerces.xni.XMLAttributes attributes,
                         org.apache.xerces.xni.Augmentations augs)
            throws org.apache.xerces.xni.XNIException
An empty element.
Specified by:
emptyElement in interface org.apache.xerces.xni.XMLDocumentHandler
Overrides:
emptyElement in interface XIncludeHandler
Parameters:
element - The name of the element.
attributes - The element attributes.
augs - Additional information that may include infoset augmentations
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

endCDATA

public void endCDATA(org.apache.xerces.xni.Augmentations augs)
            throws org.apache.xerces.xni.XNIException
The end of a CDATA section.
Specified by:
endCDATA in interface org.apache.xerces.xni.XMLDocumentHandler
Overrides:
endCDATA in interface XIncludeHandler
Parameters:
augs - Additional information that may include infoset augmentations
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

endElement

public void endElement(org.apache.xerces.xni.QName element,
                       org.apache.xerces.xni.Augmentations augs)
            throws org.apache.xerces.xni.XNIException
The end of an element.
Specified by:
endElement in interface org.apache.xerces.xni.XMLDocumentHandler
Overrides:
endElement in interface XIncludeHandler
Parameters:
element - The name of the element.
augs - Additional information that may include infoset augmentations
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

getPointerParts

public Vector getPointerParts()
Returns a Vector of XPointerPart objects
Returns:
A Vector of XPointerPart objects.

getXPointerPart

public XPointerPart getXPointerPart()
Returns the pointer part used to resolve the document fragment.
Returns:
String - The pointer part used to resolve the document fragment.

ignorableWhitespace

public void ignorableWhitespace(org.apache.xerces.xni.XMLString text,
                                org.apache.xerces.xni.Augmentations augs)
            throws org.apache.xerces.xni.XNIException
Ignorable whitespace. For this method to be called, the document source must have some way of determining that the text containing only whitespace characters should be considered ignorable. For example, the validator can determine if a length of whitespace characters in the document are ignorable based on the element content model.
Specified by:
ignorableWhitespace in interface org.apache.xerces.xni.XMLDocumentHandler
Overrides:
ignorableWhitespace in interface XIncludeHandler
Parameters:
text - The ignorable whitespace.
augs - Additional information that may include infoset augmentations
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

init

protected void init()
Initializes the XPointer Processor;

initErrorReporter

protected void initErrorReporter()
Initializes error handling objects

isChildFragmentResolved

public boolean isChildFragmentResolved()
            throws org.apache.xerces.xni.XNIException
Returns true if the XPointer expression resolves to a non-element child of the current resource fragment.

isFragmentResolved

public boolean isFragmentResolved()
            throws org.apache.xerces.xni.XNIException
Returns true if the Node fragment is resolved.
Specified by:
isFragmentResolved in interface XPointerProcessor

isXPointerResolved

public boolean isXPointerResolved()
            throws org.apache.xerces.xni.XNIException
Returns true if the XPointer successfully found a sub-resource .
Specified by:
isXPointerResolved in interface XPointerProcessor

parseXPointer

public void parseXPointer(String xpointer)
            throws org.apache.xerces.xni.XNIException
Parses the XPointer framework expression and delegates scheme specific parsing.
Specified by:
parseXPointer in interface XPointerProcessor
See Also:
org.apache.xerces.xpointer.XPointerProcessor.parseXPointer(java.lang.String)

processingInstruction

public void processingInstruction(String target,
                                  org.apache.xerces.xni.XMLString data,
                                  org.apache.xerces.xni.Augmentations augs)
            throws org.apache.xerces.xni.XNIException
A processing instruction. Processing instructions consist of a target name and, optionally, text data. The data is only meaningful to the application.

Typically, a processing instruction's data will contain a series of pseudo-attributes. These pseudo-attributes follow the form of element attributes but are not parsed or presented to the application as anything other than text. The application is responsible for parsing the data.

Specified by:
processingInstruction in interface org.apache.xerces.xni.XMLDocumentHandler
processingInstruction in interface org.apache.xerces.xni.XMLDTDHandler
Overrides:
processingInstruction in interface XIncludeHandler
Parameters:
target - The target.
data - The data or null if none specified.
augs - Additional information that may include infoset augmentations
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

resolveXPointer

public boolean resolveXPointer(org.apache.xerces.xni.QName element,
                               org.apache.xerces.xni.XMLAttributes attributes,
                               org.apache.xerces.xni.Augmentations augs,
                               int event)
            throws org.apache.xerces.xni.XNIException
Specified by:
resolveXPointer in interface XPointerProcessor
See Also:
org.apache.xerces.xpointer.XPointerProcessor.resolveXPointer(org.apache.xerces.xni.QName, org.apache.xerces.xni.XMLAttributes, org.apache.xerces.xni.Augmentations, int event)

setDocumentHandler

public void setDocumentHandler(org.apache.xerces.xni.XMLDocumentHandler handler)
Specified by:
setDocumentHandler in interface org.apache.xerces.xni.parser.XMLDocumentSource
Overrides:
setDocumentHandler in interface XIncludeHandler

setProperty

public void setProperty(String propertyId,
                        Object value)
            throws org.apache.xerces.xni.parser.XMLConfigurationException
Sets the value of a property. This method is called by the component manager any time after reset when a property changes value. Note: Components should silently ignore properties that do not affect the operation of the component.
Specified by:
setProperty in interface org.apache.xerces.xni.parser.XMLComponent
Overrides:
setProperty in interface XIncludeHandler
Parameters:
propertyId - The property identifier.
value - The value of the property.
Throws:
org.apache.xerces.xni.parser.XMLConfigurationException - Thrown for configuration error. In general, components should only throw this exception if it is really a critical error.

startCDATA

public void startCDATA(org.apache.xerces.xni.Augmentations augs)
            throws org.apache.xerces.xni.XNIException
The start of a CDATA section.
Specified by:
startCDATA in interface org.apache.xerces.xni.XMLDocumentHandler
Overrides:
startCDATA in interface XIncludeHandler
Parameters:
augs - Additional information that may include infoset augmentations
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

startElement

public void startElement(org.apache.xerces.xni.QName element,
                         org.apache.xerces.xni.XMLAttributes attributes,
                         org.apache.xerces.xni.Augmentations augs)
            throws org.apache.xerces.xni.XNIException
The start of an element.
Specified by:
startElement in interface org.apache.xerces.xni.XMLDocumentHandler
Overrides:
startElement in interface XIncludeHandler
Parameters:
element - The name of the element.
attributes - The element attributes.
augs - Additional information that may include infoset augmentations
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

Copyright B) 1999-2006 The Apache Software Foundation. All Rights Reserved.