| java.lang.Object org.apache.xerces.xinclude.XIncludeHandler
All known Subclasses: org.apache.xerces.xpointer.XPointerHandler,
XIncludeHandler | public class XIncludeHandler implements XMLComponent,XMLDocumentFilter,XMLDTDFilter(Code) | |
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:
- http://xml.org/sax/features/allow-dtd-events-after-endDTD
- http://apache.org/xml/properties/internal/error-reporter
- http://apache.org/xml/properties/internal/entity-resolver
Optional property:
- http://apache.org/xml/properties/input-buffer-size
Furthermore, the 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.
author: Peter McCracken, IBM author: Michael Glavassevich, IBM version: $Id: XIncludeHandler.java 572045 2007-09-02 17:32:09Z mrglavas $ See Also: XIncludeNamespaceSupport |
Inner Class :protected static class Notation | |
Inner Class :protected static class UnparsedEntity | |
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. | public void | attributeDecl(String elementName, String attributeName, String type, String[] enumeration, String defaultType, XMLString defaultValue, XMLString nonNormalizedDefaultValue, Augmentations augmentations) | public void | characters(XMLString text, Augmentations augs) | protected void | checkAndSendNotation(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(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. | public void | comment(XMLString text, Augmentations augs) | protected void | copyFeatures(XMLComponentManager from, ParserConfigurationSettings to) | protected void | copyFeatures(XMLComponentManager from, XMLParserConfiguration to) | public void | doctypeDecl(String rootElement, String publicId, String systemId, Augmentations augs) | public void | elementDecl(String name, String contentModel, Augmentations augmentations) | public void | emptyElement(QName element, XMLAttributes attributes, Augmentations augs) | public void | endAttlist(Augmentations augmentations) | public void | endCDATA(Augmentations augs) | public void | endConditional(Augmentations augmentations) | public void | endDTD(Augmentations augmentations) | public void | endDocument(Augmentations augs) | public void | endElement(QName element, Augmentations augs) | public void | endExternalSubset(Augmentations augmentations) | public void | endGeneralEntity(String name, Augmentations augs) | public void | endParameterEntity(String name, Augmentations augmentations) | public void | externalEntityDecl(String name, XMLResourceIdentifier identifier, Augmentations augmentations) | public String | getBaseURI(int depth) | public XMLDTDHandler | getDTDHandler() | public XMLDTDSource | getDTDSource() | public XMLDocumentHandler | getDocumentHandler() | public XMLDocumentSource | getDocumentSource() | public 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. | public String | getLanguage(int depth) Gets the language that was in use at that depth. | public 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. | public String[] | getRecognizedFeatures() Returns a list of feature identifiers that are recognized by
this component. | public 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]. | public 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) | public void | ignorableWhitespace(XMLString text, Augmentations augs) | public void | ignoredCharacters(XMLString text, Augmentations augmentations) | public 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. | public void | notationDecl(String name, XMLResourceIdentifier identifier, Augmentations augmentations) | protected XMLAttributes | processAttributes(XMLAttributes attributes) Processes the XMLAttributes object of startElement() calls. | 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. | public void | processingInstruction(String target, XMLString data, Augmentations augs) | protected void | reportFatalError(String key) | protected void | reportFatalError(String key, Object[] args) | protected void | reportResourceError(String key) | protected void | reportResourceError(String key, Object[] args) | public void | reset(XMLComponentManager componentManager) | protected void | restoreBaseURI() Discards the URIs at the top of the stack, and restores the ones beneath it. | public 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(String includedSysId) Checks if the file indicated by the given system id has already been
included in the current stack. | public void | setDTDHandler(XMLDTDHandler handler) | public void | setDTDSource(XMLDTDSource source) | public void | setDocumentHandler(XMLDocumentHandler handler) | public void | setDocumentSource(XMLDocumentSource source) | public void | setFeature(String featureId, boolean state) Sets the state of a feature. | protected void | setHref(String href) | protected void | setParent(XIncludeHandler parent) | public 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) | protected void | setXIncludeLocator(XMLLocatorWrapper locator) | protected void | setupCurrentBaseURI(XMLLocator locator) | public void | startAttlist(String elementName, Augmentations augmentations) | public void | startCDATA(Augmentations augs) | public void | startConditional(short type, Augmentations augmentations) | public void | startDTD(XMLLocator locator, Augmentations augmentations) | public void | startDocument(XMLLocator locator, String encoding, NamespaceContext namespaceContext, Augmentations augs) Event sent at the start of the document. | public void | startElement(QName element, XMLAttributes attributes, Augmentations augs) | public void | startExternalSubset(XMLResourceIdentifier identifier, Augmentations augmentations) | public void | startGeneralEntity(String name, XMLResourceIdentifier resId, String encoding, Augmentations augs) | public void | startParameterEntity(String name, XMLResourceIdentifier identifier, String encoding, Augmentations augmentations) | public void | textDecl(String version, String encoding, Augmentations augs) | public void | unparsedEntityDecl(String name, XMLResourceIdentifier identifier, String notation, Augmentations augmentations) | public void | xmlDecl(String version, String encoding, String standalone, Augmentations augs) |
ALLOW_UE_AND_NOTATION_EVENTS | final protected static String ALLOW_UE_AND_NOTATION_EVENTS(Code) | | Feature identifier: allow notation and unparsed entity events to be sent out of order.
|
BUFFER_SIZE | final protected static String BUFFER_SIZE(Code) | | property identifier: buffer size.
|
CURRENT_BASE_URI | final public static String CURRENT_BASE_URI(Code) | | The identifier for the Augmentation that contains the current base URI
|
DYNAMIC_VALIDATION | final protected static String DYNAMIC_VALIDATION(Code) | | Feature identifier: dynamic validation.
|
ENTITY_RESOLVER | final protected static String ENTITY_RESOLVER(Code) | | Property identifier: entity resolver.
|
ERROR_REPORTER | final protected static String ERROR_REPORTER(Code) | | Property identifier: error reporter.
|
HTTP_ACCEPT_LANGUAGE | final public static String HTTP_ACCEPT_LANGUAGE(Code) | | |
JAXP_SCHEMA_LANGUAGE | final protected static String JAXP_SCHEMA_LANGUAGE(Code) | | Property identifier: JAXP schema language.
|
PARSER_SETTINGS | final protected static String PARSER_SETTINGS(Code) | | |
SCHEMA_VALIDATION | final protected static String SCHEMA_VALIDATION(Code) | | Feature identifier: schema validation.
|
SECURITY_MANAGER | final protected static String SECURITY_MANAGER(Code) | | property identifier: security manager.
|
SYMBOL_TABLE | final protected static String SYMBOL_TABLE(Code) | | Property identifier: symbol table.
|
VALIDATION | final protected static String VALIDATION(Code) | | Feature identifier: validation.
|
XINCLUDE_ATTR_ACCEPT | final public static String XINCLUDE_ATTR_ACCEPT(Code) | | |
XINCLUDE_ATTR_ACCEPT_LANGUAGE | final public static String XINCLUDE_ATTR_ACCEPT_LANGUAGE(Code) | | |
XINCLUDE_ATTR_ENCODING | final public static String XINCLUDE_ATTR_ENCODING(Code) | | |
XINCLUDE_ATTR_HREF | final public static String XINCLUDE_ATTR_HREF(Code) | | |
XINCLUDE_ATTR_PARSE | final public static String XINCLUDE_ATTR_PARSE(Code) | | |
XINCLUDE_DEFAULT_CONFIGURATION | final public static String XINCLUDE_DEFAULT_CONFIGURATION(Code) | | |
XINCLUDE_FALLBACK | final public static String XINCLUDE_FALLBACK(Code) | | |
XINCLUDE_FIXUP_BASE_URIS | final protected static String XINCLUDE_FIXUP_BASE_URIS(Code) | | Feature identifier: fixup base URIs.
|
XINCLUDE_FIXUP_LANGUAGE | final protected static String XINCLUDE_FIXUP_LANGUAGE(Code) | | Feature identifier: fixup language.
|
XINCLUDE_INCLUDE | final public static String XINCLUDE_INCLUDE(Code) | | |
XINCLUDE_INCLUDED | final public static String XINCLUDE_INCLUDED(Code) | | |
XINCLUDE_NS_URI | final public static String XINCLUDE_NS_URI(Code) | | |
XINCLUDE_PARSE_TEXT | final public static String XINCLUDE_PARSE_TEXT(Code) | | |
XINCLUDE_PARSE_XML | final public static String XINCLUDE_PARSE_XML(Code) | | |
fBufferSize | protected int fBufferSize(Code) | | |
fExpandedSystemID | final protected Stack fExpandedSystemID(Code) | | |
fHasIncludeReportedContent | boolean fHasIncludeReportedContent(Code) | | |
fLanguageStack | final protected Stack fLanguageStack(Code) | | |
fLiteralSystemID | final protected Stack fLiteralSystemID(Code) | | |
XIncludeHandler | public XIncludeHandler()(Code) | | |
addNotation | protected void addNotation(String name, XMLResourceIdentifier identifier, Augmentations augmentations)(Code) | | Caches a notation.
Parameters: name - the name of the notation Parameters: identifier - the location of the notation Parameters: augmentations - any Augmentations that were on the original notation declaration |
addUnparsedEntity | protected void addUnparsedEntity(String name, XMLResourceIdentifier identifier, String notation, Augmentations augmentations)(Code) | | Caches an unparsed entity.
Parameters: name - the name of the unparsed entity Parameters: identifier - the location of the unparsed entity Parameters: augmentations - any Augmentations that were on the original unparsed entity declaration |
checkAndSendNotation | protected void checkAndSendNotation(Notation not)(Code) | | The purpose of this method is to check if a Notation conflicts with a previously
declared notation in the current pipeline stack. If there is no conflict, the
Notation is sent by the root pipeline.
Parameters: not - the Notation to check for conflicts |
checkAndSendUnparsedEntity | protected void checkAndSendUnparsedEntity(UnparsedEntity ent)(Code) | | The purpose of this method is to check if an UnparsedEntity conflicts with a previously
declared entity in the current pipeline stack. If there is no conflict, the
UnparsedEntity is sent by the root pipeline.
Parameters: ent - the UnparsedEntity to check for conflicts |
checkNotation | protected void checkNotation(String notName)(Code) | | Checks if a Notation with the given name was declared in the DTD of the document
for the current pipeline. If so, that Notation is passed to the root pipeline to
be checked for conflicts, and sent to the root DTDHandler
Parameters: notName - the name of the Notation to check |
checkUnparsedEntity | protected void checkUnparsedEntity(String entName)(Code) | | Checks if an UnparsedEntity with the given name was declared in the DTD of the document
for the current pipeline. If so, then the notation for the UnparsedEntity is checked.
If that turns out okay, then the UnparsedEntity is passed to the root pipeline to
be checked for conflicts, and sent to the root DTDHandler.
Parameters: entName - the name of the UnparsedEntity to check |
getBaseURI | public String getBaseURI(int depth)(Code) | | Gets the base URI that was in use at that depth
Parameters: depth - the base URI |
getFeatureDefault | public Boolean getFeatureDefault(String featureId)(Code) | | Returns the default state for a feature, or null if this
component does not want to report a default value for this
feature.
Parameters: featureId - The feature identifier. since: Xerces 2.2.0 |
getLanguage | public String getLanguage(int depth)(Code) | | Gets the language that was in use at that depth.
Parameters: depth - the language |
getPropertyDefault | public Object getPropertyDefault(String propertyId)(Code) | | Returns the default state for a property, or null if this
component does not want to report a default value for this
property.
Parameters: propertyId - The property identifier. since: Xerces 2.2.0 |
getRecognizedFeatures | public String[] getRecognizedFeatures()(Code) | | Returns a list of feature identifiers that are recognized by
this component. This method may return null if no features
are recognized by this component.
|
getRecognizedProperties | public String[] getRecognizedProperties()(Code) | | Returns a list of property identifiers that are recognized by
this component. This method may return null if no properties
are recognized by this component.
|
getRelativeBaseURI | protected String getRelativeBaseURI() throws MalformedURIException(Code) | | Returns a URI, relative to the include parent's base URI, of the current
[base URI]. For instance, if the current [base URI] was "dir1/dir2/file.xml"
and the include parent's [base URI] was "dir/", this would return "dir2/file.xml".
the relative URI |
getRelativeURI | public String getRelativeURI(int depth) throws MalformedURIException(Code) | | Returns a relative URI, which when resolved against the base URI at the
specified depth, will create the current base URI.
This is accomplished by merged the literal system IDs.
Parameters: depth - the depth at which to start creating the relative URI a relative URI to convert the base URI at the given depth to the currentbase URI |
getSawFallback | protected boolean getSawFallback(int depth)(Code) | | 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.
Parameters: depth - |
getSawInclude | protected boolean getSawInclude(int depth)(Code) | | Return whether an <include> was encountered at the specified depth,
as an ancestor of the current item.
Parameters: depth - true if an include was seen at the given depth, false otherwise |
getState | protected int getState(int depth)(Code) | | |
getState | protected int getState()(Code) | | |
handleFallbackElement | protected void handleFallbackElement()(Code) | | |
hasXIncludeNamespace | protected boolean hasXIncludeNamespace(QName element)(Code) | | Returns true if the element has the namespace "http://www.w3.org/2001/XInclude"
Parameters: element - the element to check true if the element has the namespace "http://www.w3.org/2001/XInclude" |
isFallbackElement | protected boolean isFallbackElement(QName element)(Code) | | Checks if the element is an <fallback> element. The element must have
the XInclude namespace, and a local name of "fallback".
Parameters: element - the element to check true if the element is an <fallback; element See Also: XIncludeHandler.hasXIncludeNamespace(QName) |
isIncludeElement | protected boolean isIncludeElement(QName element)(Code) | | Checks if the element is an <include> element. The element must have
the XInclude namespace, and a local name of "include".
Parameters: element - the element to check true if the element is an <include> element See Also: XIncludeHandler.hasXIncludeNamespace(QName) |
isRootDocument | protected boolean isRootDocument()(Code) | | |
isTopLevelIncludedItem | protected boolean isTopLevelIncludedItem()(Code) | | Returns true if the current element is a top level included item. This means
it's either the child of a fallback element, or the top level item in an
included document
true if the current element is a top level included item |
isTopLevelIncludedItemViaFallback | protected boolean isTopLevelIncludedItemViaFallback()(Code) | | |
isTopLevelIncludedItemViaInclude | protected boolean isTopLevelIncludedItemViaInclude()(Code) | | |
modifyAugmentations | protected Augmentations modifyAugmentations(Augmentations augs)(Code) | | Modify the augmentations. Add an [included] infoset item, if the current
element is a top level included item.
Parameters: augs - the Augmentations to modify. the modified Augmentations |
modifyAugmentations | protected Augmentations modifyAugmentations(Augmentations augs, boolean force)(Code) | | Modify the augmentations. Add an [included] infoset item, if force
is true, or if the current element is a top level included item.
Parameters: augs - the Augmentations to modify. Parameters: force - whether to force modification the modified Augmentations |
processAttributes | protected XMLAttributes processAttributes(XMLAttributes attributes)(Code) | | Processes the XMLAttributes object of startElement() calls. Performs the following tasks:
- If the element is a top level included item whose [base URI] is different from the
[base URI] of the include parent, then an xml:base attribute is added to specify the
true [base URI]
- For all namespace prefixes which are in-scope in an included item, but not in scope
in the include parent, a xmlns:prefix attribute is added
- For all attributes with a type of ENTITY, ENTITIES or NOTATIONS, the notations and
unparsed entities are processed as described in the spec, sections 4.5.1 and 4.5.2
Parameters: attributes - the processed XMLAttributes |
processXMLBaseAttributes | protected void processXMLBaseAttributes(XMLAttributes attributes)(Code) | | Search for a xml:base attribute, and if one is found, put the new base URI into
effect.
|
processXMLLangAttributes | protected void processXMLLangAttributes(XMLAttributes attributes)(Code) | | Search for a xml:lang attribute, and if one is found, put the new
[language] into effect.
|
reportFatalError | protected void reportFatalError(String key)(Code) | | |
reportResourceError | protected void reportResourceError(String key)(Code) | | |
restoreBaseURI | protected void restoreBaseURI()(Code) | | Discards the URIs at the top of the stack, and restores the ones beneath it.
|
restoreLanguage | public String restoreLanguage()(Code) | | Discards the language at the top of the stack, and returns the one beneath it.
|
sameBaseURIAsIncludeParent | protected boolean sameBaseURIAsIncludeParent()(Code) | | Returns true if the current [base URI] is the same as the [base URI] that
was in effect on the include parent. This method should only be called
when the current element is a top level included element, i.e. the direct child
of a fallback element, or the root elements in an included document.
The "include parent" is the element which, in the result infoset, will be the
direct parent of the current element.
true if the [base URIs] are the same string |
sameLanguageAsIncludeParent | protected boolean sameLanguageAsIncludeParent()(Code) | | 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]. This method should only be called when the
current element is a top level included element, i.e. the direct child
of a fallback element, or the root elements in an included document.
The "include parent" is the element which, in the result infoset, will be the
direct parent of the current element.
true if the [language] properties have the same valuetaking case-insensitivity into account as per [RFC 3066]. |
saveBaseURI | protected void saveBaseURI()(Code) | | Saves the current base URI to the top of the stack.
|
saveLanguage | protected void saveLanguage(String language)(Code) | | Saves the given language on the top of the stack.
Parameters: language - the language to push onto the stack. |
searchForRecursiveIncludes | protected boolean searchForRecursiveIncludes(String includedSysId)(Code) | | Checks if the file indicated by the given system id has already been
included in the current stack.
Parameters: includedSysId - the system id to check for inclusion true if the source has already been included |
setFeature | public void setFeature(String featureId, boolean state) throws XMLConfigurationException(Code) | | Sets the state of a feature. This method is called by the component
manager any time after reset when a feature changes state.
Note: Components should silently ignore features
that do not affect the operation of the component.
Parameters: featureId - The feature identifier. Parameters: state - The state of the feature. throws: SAXNotRecognizedException - The component should not throwthis exception. throws: SAXNotSupportedException - The component should not throwthis exception. |
setParent | protected void setParent(XIncludeHandler parent)(Code) | | Set the parent of this XIncludeHandler in the tree
Parameters: parent - |
setProperty | public void setProperty(String propertyId, Object value) throws XMLConfigurationException(Code) | | 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.
Parameters: propertyId - The property identifier. Parameters: value - The value of the property. throws: SAXNotRecognizedException - The component should not throwthis exception. throws: SAXNotSupportedException - The component should not throwthis exception. |
setSawFallback | protected void setSawFallback(int depth, boolean val)(Code) | | 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.
Parameters: depth - Parameters: val - |
setSawInclude | protected void setSawInclude(int depth, boolean val)(Code) | | Records that an <include> was encountered at the specified depth,
as an ancestor of the current item.
Parameters: depth - Parameters: val - |
setState | protected void setState(int state)(Code) | | |
startDocument | public void startDocument(XMLLocator locator, String encoding, NamespaceContext namespaceContext, Augmentations augs) throws XNIException(Code) | | Event sent at the start of the document.
A fatal error will occur here, if it is detected that this document has been processed
before.
This event is only passed on to the document handler if this is the root document.
|
|
|