org.apache.xerces.xinclude
public class XIncludeHandler extends Object implements XMLComponent, XMLDocumentFilter, XMLDTDFilter
This is a pipeline component which performs XInclude handling, according to the W3C specification for XML Inclusions.
This component analyzes each event in the pipeline, looking for <include>
elements. An <include> element is one which has a namespace of
http://www.w3.org/2001/XInclude
and a localname of include
.
When it finds an <include> element, it attempts to include the file specified
in the href
attribute of the element. If inclusion succeeds, all
children of the <include> element are ignored (with the exception of
checking for invalid children as outlined in the specification). If the inclusion
fails, the <fallback> child of the <include> element is processed.
See the XInclude specification for more information on how XInclude is to be used.
This component requires the following features and properties from the component manager that uses it:
NamespaceContext
used in the pipeline is required
to be an instance of XIncludeNamespaceSupport
.
Currently, this implementation has only partial support for the XInclude specification. Specifically, it is missing support for XPointer document fragments. Thus, only whole documents can be included using this component in the pipeline.
Version: $Id: XIncludeHandler.java,v 1.56 2005/07/25 18:04:26 mrglavas Exp $
See Also: XIncludeNamespaceSupport
Nested Class Summary | |
---|---|
protected static class | XIncludeHandler.Notation |
protected static class | XIncludeHandler.UnparsedEntity |
Field Summary | |
---|---|
protected static String | ALLOW_UE_AND_NOTATION_EVENTS Feature identifier: allow notation and unparsed entity events to be sent out of order. |
static String | BUFFER_SIZE property identifier: buffer size. |
static String | CURRENT_BASE_URI The identifier for the Augmentation that contains the current base URI |
protected static String | DYNAMIC_VALIDATION Feature identifier: dynamic validation. |
protected static String | ENTITY_RESOLVER Property identifier: entity resolver. |
protected static String | ERROR_REPORTER Property identifier: error reporter. |
protected Stack | fBaseURI |
protected IntStack | fBaseURIScope |
protected int | fBufferSize |
protected XMLParserConfiguration | fChildConfig |
protected XMLResourceIdentifier | fCurrentBaseURI |
protected String | fCurrentLanguage |
protected XMLLocator | fDocLocation |
protected XMLDocumentHandler | fDocumentHandler |
protected XMLDocumentSource | fDocumentSource |
protected XMLDTDHandler | fDTDHandler |
protected XMLDTDSource | fDTDSource |
protected XMLEntityResolver | fEntityResolver |
protected XMLErrorReporter | fErrorReporter |
protected Stack | fExpandedSystemID |
protected IntStack | fLanguageScope |
protected Stack | fLanguageStack |
protected Stack | fLiteralSystemID |
protected XIncludeNamespaceSupport | fNamespaceContext |
protected String | fParentRelativeURI |
protected XIncludeHandler | fParentXIncludeHandler |
protected SecurityManager | fSecurityManager |
protected ParserConfigurationSettings | fSettings |
protected SymbolTable | fSymbolTable |
protected XIncludeTextReader | fXInclude10TextReader |
protected XIncludeTextReader | fXInclude11TextReader |
protected XMLParserConfiguration | fXIncludeChildConfig |
protected XIncludeMessageFormatter | fXIncludeMessageFormatter |
protected XMLParserConfiguration | fXPointerChildConfig |
protected XPointerProcessor | fXPtrProcessor |
static String | HTTP_ACCEPT |
static String | HTTP_ACCEPT_LANGUAGE |
static QName | NEW_NS_ATTR_QNAME |
protected static String | PARSER_SETTINGS |
protected static String | SCHEMA_VALIDATION Feature identifier: schema validation. |
protected static String | SECURITY_MANAGER property identifier: security manager. |
protected static String | SYMBOL_TABLE Property identifier: symbol table. |
protected static String | VALIDATION Feature identifier: validation. |
static String | XINCLUDE_ATTR_ACCEPT |
static String | XINCLUDE_ATTR_ACCEPT_LANGUAGE |
static String | XINCLUDE_ATTR_ENCODING |
static String | XINCLUDE_ATTR_HREF |
static String | XINCLUDE_ATTR_PARSE |
static String | XINCLUDE_BASE |
static String | XINCLUDE_DEFAULT_CONFIGURATION |
static String | XINCLUDE_FALLBACK |
protected static String | XINCLUDE_FIXUP_BASE_URIS Feature identifier: fixup base URIs. |
protected static String | XINCLUDE_FIXUP_LANGUAGE Feature identifier: fixup language. |
static String | XINCLUDE_INCLUDE |
static String | XINCLUDE_INCLUDED |
static String | XINCLUDE_LANG |
static String | XINCLUDE_NS_URI |
static String | XINCLUDE_PARSE_TEXT |
static String | XINCLUDE_PARSE_XML |
static QName | XML_BASE_QNAME |
static QName | XML_LANG_QNAME |
static String | XPOINTER |
Constructor Summary | |
---|---|
XIncludeHandler() |
Method Summary | |
---|---|
protected void | addNotation(String name, XMLResourceIdentifier identifier, Augmentations augmentations)
Caches a notation. |
protected void | addUnparsedEntity(String name, XMLResourceIdentifier identifier, String notation, Augmentations augmentations)
Caches an unparsed entity. |
void | attributeDecl(String elementName, String attributeName, String type, String[] enumeration, String defaultType, XMLString defaultValue, XMLString nonNormalizedDefaultValue, Augmentations augmentations) |
void | characters(XMLString text, Augmentations augs) |
protected void | checkAndSendNotation(XIncludeHandler.Notation not)
The purpose of this method is to check if a Notation conflicts with a previously
declared notation in the current pipeline stack. |
protected void | checkAndSendUnparsedEntity(XIncludeHandler.UnparsedEntity ent)
The purpose of this method is to check if an UnparsedEntity conflicts with a previously
declared entity in the current pipeline stack. |
protected void | checkNotation(String notName)
Checks if a Notation with the given name was declared in the DTD of the document
for the current pipeline. |
protected void | checkUnparsedEntity(String entName)
Checks if an UnparsedEntity with the given name was declared in the DTD of the document
for the current pipeline. |
void | comment(XMLString text, Augmentations augs) |
protected void | copyFeatures(XMLComponentManager from, ParserConfigurationSettings to) |
protected void | copyFeatures(XMLComponentManager from, XMLParserConfiguration to) |
void | doctypeDecl(String rootElement, String publicId, String systemId, Augmentations augs) |
void | elementDecl(String name, String contentModel, Augmentations augmentations) |
void | emptyElement(QName element, XMLAttributes attributes, Augmentations augs) |
void | endAttlist(Augmentations augmentations) |
void | endCDATA(Augmentations augs) |
void | endConditional(Augmentations augmentations) |
void | endDocument(Augmentations augs) |
void | endDTD(Augmentations augmentations) |
void | endElement(QName element, Augmentations augs) |
void | endExternalSubset(Augmentations augmentations) |
void | endGeneralEntity(String name, Augmentations augs) |
void | endParameterEntity(String name, Augmentations augmentations) |
void | externalEntityDecl(String name, XMLResourceIdentifier identifier, Augmentations augmentations) |
String | getBaseURI(int depth)
Gets the base URI that was in use at that depth |
XMLDocumentHandler | getDocumentHandler() |
XMLDocumentSource | getDocumentSource() |
XMLDTDHandler | getDTDHandler() |
XMLDTDSource | getDTDSource() |
Boolean | getFeatureDefault(String featureId)
Returns the default state for a feature, or null if this
component does not want to report a default value for this
feature.
|
String | getLanguage(int depth)
Gets the language that was in use at that depth. |
Object | getPropertyDefault(String propertyId)
Returns the default state for a property, or null if this
component does not want to report a default value for this
property.
|
String[] | getRecognizedFeatures()
Returns a list of feature identifiers that are recognized by
this component. |
String[] | getRecognizedProperties()
Returns a list of property identifiers that are recognized by
this component. |
protected String | getRelativeBaseURI()
Returns a URI, relative to the include parent's base URI, of the current
[base URI]. |
String | getRelativeURI(int depth)
Returns a relative URI, which when resolved against the base URI at the
specified depth, will create the current base URI.
|
protected boolean | getSawFallback(int depth)
Returns whether an <fallback> was encountered at the specified depth,
as an ancestor of the current element, or as a sibling of an ancestor of the
current element.
|
protected boolean | getSawInclude(int depth)
Return whether an <include> was encountered at the specified depth,
as an ancestor of the current item.
|
protected int | getState(int depth) |
protected int | getState() |
protected void | handleFallbackElement() |
protected boolean | handleIncludeElement(XMLAttributes attributes) |
protected boolean | hasXIncludeNamespace(QName element)
Returns true if the element has the namespace "http://www.w3.org/2001/XInclude" |
void | ignorableWhitespace(XMLString text, Augmentations augs) |
void | ignoredCharacters(XMLString text, Augmentations augmentations) |
void | internalEntityDecl(String name, XMLString text, XMLString nonNormalizedText, Augmentations augmentations) |
protected boolean | isFallbackElement(QName element)
Checks if the element is an <fallback> element. |
protected boolean | isIncludeElement(QName element)
Checks if the element is an <include> element. |
protected boolean | isRootDocument() |
protected boolean | isTopLevelIncludedItem()
Returns true if the current element is a top level included item. |
protected boolean | isTopLevelIncludedItemViaFallback() |
protected boolean | isTopLevelIncludedItemViaInclude() |
protected Augmentations | modifyAugmentations(Augmentations augs)
Modify the augmentations. |
protected Augmentations | modifyAugmentations(Augmentations augs, boolean force)
Modify the augmentations. |
void | notationDecl(String name, XMLResourceIdentifier identifier, Augmentations augmentations) |
protected XMLAttributes | processAttributes(XMLAttributes attributes)
Processes the XMLAttributes object of startElement() calls. |
void | processingInstruction(String target, XMLString data, Augmentations augs) |
protected void | processXMLBaseAttributes(XMLAttributes attributes)
Search for a xml:base attribute, and if one is found, put the new base URI into
effect. |
protected void | processXMLLangAttributes(XMLAttributes attributes)
Search for a xml:lang attribute, and if one is found, put the new
[language] into effect. |
protected void | reportFatalError(String key) |
protected void | reportFatalError(String key, Object[] args) |
protected void | reportResourceError(String key) |
protected void | reportResourceError(String key, Object[] args) |
void | reset(XMLComponentManager componentManager) |
protected void | restoreBaseURI()
Discards the URIs at the top of the stack, and restores the ones beneath it. |
String | restoreLanguage()
Discards the language at the top of the stack, and returns the one beneath it. |
protected boolean | sameBaseURIAsIncludeParent()
Returns true if the current [base URI] is the same as the [base URI] that
was in effect on the include parent. |
protected boolean | sameLanguageAsIncludeParent()
Returns true if the current [language] is equivalent to the [language] that
was in effect on the include parent, taking case-insensitivity into account
as per [RFC 3066]. |
protected void | saveBaseURI()
Saves the current base URI to the top of the stack. |
protected void | saveLanguage(String language)
Saves the given language on the top of the stack.
|
protected boolean | searchForRecursiveIncludes(XMLLocator includedSource)
Checks if the file indicated by the given XMLLocator has already been included
in the current stack. |
void | setDocumentHandler(XMLDocumentHandler handler) |
void | setDocumentSource(XMLDocumentSource source) |
void | setDTDHandler(XMLDTDHandler handler) |
void | setDTDSource(XMLDTDSource source) |
void | setFeature(String featureId, boolean state)
Sets the state of a feature. |
protected void | setParent(XIncludeHandler parent)
Set the parent of this XIncludeHandler in the tree |
void | setProperty(String propertyId, Object value)
Sets the value of a property. |
protected void | setSawFallback(int depth, boolean val)
Records that an <fallback> was encountered at the specified depth,
as an ancestor of the current element, or as a sibling of an ancestor of the
current element.
|
protected void | setSawInclude(int depth, boolean val)
Records that an <include> was encountered at the specified depth,
as an ancestor of the current item.
|
protected void | setState(int state) |
void | startAttlist(String elementName, Augmentations augmentations) |
void | startCDATA(Augmentations augs) |
void | startConditional(short type, Augmentations augmentations) |
void | startDocument(XMLLocator locator, String encoding, NamespaceContext namespaceContext, Augmentations augs)
Event sent at the start of the document.
|
void | startDTD(XMLLocator locator, Augmentations augmentations) |
void | startElement(QName element, XMLAttributes attributes, Augmentations augs) |
void | startExternalSubset(XMLResourceIdentifier identifier, Augmentations augmentations) |
void | startGeneralEntity(String name, XMLResourceIdentifier resId, String encoding, Augmentations augs) |
void | startParameterEntity(String name, XMLResourceIdentifier identifier, String encoding, Augmentations augmentations) |
void | textDecl(String version, String encoding, Augmentations augs) |
void | unparsedEntityDecl(String name, XMLResourceIdentifier identifier, String notation, Augmentations augmentations) |
void | xmlDecl(String version, String encoding, String standalone, Augmentations augs) |
Parameters: name the name of the notation identifier the location of the notation augmentations any Augmentations that were on the original notation declaration
Parameters: name the name of the unparsed entity identifier the location of the unparsed entity augmentations any Augmentations that were on the original unparsed entity declaration
Parameters: not the Notation to check for conflicts
Parameters: ent the UnparsedEntity to check for conflicts
Parameters: notName the name of the Notation to check
Parameters: entName the name of the UnparsedEntity to check
Parameters: depth
Returns: the base URI
Parameters: featureId The feature identifier.
Since: Xerces 2.2.0
Parameters: depth
Returns: the language
Parameters: propertyId The property identifier.
Since: Xerces 2.2.0
Returns: the relative URI
Parameters: depth the depth at which to start creating the relative URI
Returns: a relative URI to convert the base URI at the given depth to the current base URI
Parameters: depth
Parameters: depth
Returns:
Parameters: element the element to check
Returns: true if the element has the namespace "http://www.w3.org/2001/XInclude"
Parameters: element the element to check
Returns: true if the element is an <fallback; element
See Also: hasXIncludeNamespace
Parameters: element the element to check
Returns: true if the element is an <include> element
See Also: hasXIncludeNamespace
Returns: true if the current element is a top level included item
Parameters: augs the Augmentations to modify.
Returns: the modified Augmentations
force
is true, or if the current element is a top level included item.Parameters: augs the Augmentations to modify. force whether to force modification
Returns: the modified Augmentations
Parameters: attributes
Returns:
Returns: true if the [base URIs] are the same string
Returns: true if the [language] properties have the same value taking case-insensitivity into account as per [RFC 3066].
Parameters: lanaguage the language to push onto the stack.
Parameters: includedSource the source to check for inclusion
Returns: true if the source has already been included
Note: Components should silently ignore features that do not affect the operation of the component.
Parameters: featureId The feature identifier. state The state of the feature.
Throws: SAXNotRecognizedException The component should not throw this exception. SAXNotSupportedException The component should not throw this exception.
Parameters: parent
Note: Components should silently ignore properties that do not affect the operation of the component.
Parameters: propertyId The property identifier. value The value of the property.
Throws: SAXNotRecognizedException The component should not throw this exception. SAXNotSupportedException The component should not throw this exception.
Parameters: depth val
Parameters: depth val