Save This Page
Home » Xerces-J-src.2.9.1 » org.apache.xerces » xinclude » [javadoc | source]
org.apache.xerces.xinclude
public class: XIncludeHandler [javadoc | source]
java.lang.Object
   org.apache.xerces.xinclude.XIncludeHandler

All Implemented Interfaces:
    XMLComponent, XMLDocumentFilter, XMLDTDFilter

Direct Known Subclasses:
    XPointerHandler

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:

Optional property: 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.

Nested Class Summary:
protected static class  XIncludeHandler.Notation   
protected static class  XIncludeHandler.UnparsedEntity   
Field Summary
public static final  String XINCLUDE_DEFAULT_CONFIGURATION     
public static final  String HTTP_ACCEPT     
public static final  String HTTP_ACCEPT_LANGUAGE     
public static final  String XPOINTER     
public static final  String XINCLUDE_NS_URI     
public static final  String XINCLUDE_INCLUDE     
public static final  String XINCLUDE_FALLBACK     
public static final  String XINCLUDE_PARSE_XML     
public static final  String XINCLUDE_PARSE_TEXT     
public static final  String XINCLUDE_ATTR_HREF     
public static final  String XINCLUDE_ATTR_PARSE     
public static final  String XINCLUDE_ATTR_ENCODING     
public static final  String XINCLUDE_ATTR_ACCEPT     
public static final  String XINCLUDE_ATTR_ACCEPT_LANGUAGE     
public static final  String XINCLUDE_INCLUDED     
public static final  String CURRENT_BASE_URI    The identifier for the Augmentation that contains the current base URI 
protected static final  String VALIDATION    Feature identifier: validation. 
protected static final  String SCHEMA_VALIDATION    Feature identifier: schema validation. 
protected static final  String DYNAMIC_VALIDATION    Feature identifier: dynamic validation. 
protected static final  String ALLOW_UE_AND_NOTATION_EVENTS    Feature identifier: allow notation and unparsed entity events to be sent out of order. 
protected static final  String XINCLUDE_FIXUP_BASE_URIS    Feature identifier: fixup base URIs. 
protected static final  String XINCLUDE_FIXUP_LANGUAGE    Feature identifier: fixup language. 
protected static final  String JAXP_SCHEMA_LANGUAGE    Property identifier: JAXP schema language. 
protected static final  String SYMBOL_TABLE    Property identifier: symbol table. 
protected static final  String ERROR_REPORTER    Property identifier: error reporter. 
protected static final  String ENTITY_RESOLVER    Property identifier: entity resolver. 
protected static final  String SECURITY_MANAGER    property identifier: security manager. 
protected static final  String BUFFER_SIZE    property identifier: buffer size. 
protected static final  String PARSER_SETTINGS     
protected  XMLDocumentHandler fDocumentHandler     
protected  XMLDocumentSource fDocumentSource     
protected  XMLDTDHandler fDTDHandler     
protected  XMLDTDSource fDTDSource     
protected  XIncludeHandler fParentXIncludeHandler     
protected  int fBufferSize     
protected  String fParentRelativeURI     
protected  XMLParserConfiguration fChildConfig     
protected  XMLParserConfiguration fXIncludeChildConfig     
protected  XMLParserConfiguration fXPointerChildConfig     
protected  XPointerProcessor fXPtrProcessor     
protected  XMLLocator fDocLocation     
protected  XMLLocatorWrapper fXIncludeLocator     
protected  XIncludeMessageFormatter fXIncludeMessageFormatter     
protected  XIncludeNamespaceSupport fNamespaceContext     
protected  SymbolTable fSymbolTable     
protected  XMLErrorReporter fErrorReporter     
protected  XMLEntityResolver fEntityResolver     
protected  SecurityManager fSecurityManager     
protected  XIncludeTextReader fXInclude10TextReader     
protected  XIncludeTextReader fXInclude11TextReader     
protected final  XMLResourceIdentifier fCurrentBaseURI     
protected final  IntStack fBaseURIScope     
protected final  Stack fBaseURI     
protected final  Stack fLiteralSystemID     
protected final  Stack fExpandedSystemID     
protected final  IntStack fLanguageScope     
protected final  Stack fLanguageStack     
protected  String fCurrentLanguage     
protected  String fHrefFromParent     
protected  ParserConfigurationSettings fSettings     
 boolean fHasIncludeReportedContent     
Constructor:
 public XIncludeHandler() 
Method from org.apache.xerces.xinclude.XIncludeHandler Summary:
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,   setXIncludeLocator,   setupCurrentBaseURI,   startAttlist,   startCDATA,   startConditional,   startDTD,   startDocument,   startElement,   startExternalSubset,   startGeneralEntity,   startParameterEntity,   textDecl,   unparsedEntityDecl,   xmlDecl
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.xerces.xinclude.XIncludeHandler Detail:
 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) throws XNIException 
 public  void characters(XMLString text,
    Augmentations augs) throws XNIException 
 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. If there is no conflict, the Notation is sent by the root pipeline.
 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. If there is no conflict, the UnparsedEntity is sent by the root pipeline.
 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. If so, that Notation is passed to the root pipeline to be checked for conflicts, and sent to the root DTDHandler
 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. 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.
 public  void comment(XMLString text,
    Augmentations augs) throws XNIException 
 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) throws XNIException 
 public  void elementDecl(String name,
    String contentModel,
    Augmentations augmentations) throws XNIException 
 public  void emptyElement(QName element,
    XMLAttributes attributes,
    Augmentations augs) throws XNIException 
 public  void endAttlist(Augmentations augmentations) throws XNIException 
 public  void endCDATA(Augmentations augs) throws XNIException 
 public  void endConditional(Augmentations augmentations) throws XNIException 
 public  void endDTD(Augmentations augmentations) throws XNIException 
 public  void endDocument(Augmentations augs) throws XNIException 
 public  void endElement(QName element,
    Augmentations augs) throws XNIException 
 public  void endExternalSubset(Augmentations augmentations) throws XNIException 
 public  void endGeneralEntity(String name,
    Augmentations augs) throws XNIException 
 public  void endParameterEntity(String name,
    Augmentations augmentations) throws XNIException 
 public  void externalEntityDecl(String name,
    XMLResourceIdentifier identifier,
    Augmentations augmentations) throws XNIException 
 public String getBaseURI(int depth) 
    Gets the base URI that was in use at that 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. This method may return null if no features are recognized by this component.
 public String[] getRecognizedProperties() 
    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.
 protected String getRelativeBaseURI() throws MalformedURIException 
    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".
 public String getRelativeURI(int depth) throws MalformedURIException 
    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.
 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() 
 protected int getState(int depth) 
 protected  void handleFallbackElement() 
 protected boolean handleIncludeElement(XMLAttributes attributes) throws XNIException 
 protected boolean hasXIncludeNamespace(QName element) 
    Returns true if the element has the namespace "http://www.w3.org/2001/XInclude"
 public  void ignorableWhitespace(XMLString text,
    Augmentations augs) throws XNIException 
 public  void ignoredCharacters(XMLString text,
    Augmentations augmentations) throws XNIException 
 public  void internalEntityDecl(String name,
    XMLString text,
    XMLString nonNormalizedText,
    Augmentations augmentations) throws XNIException 
 protected boolean isFallbackElement(QName element) 
    Checks if the element is an <fallback> element. The element must have the XInclude namespace, and a local name of "fallback".
 protected boolean isIncludeElement(QName element) 
    Checks if the element is an <include> element. The element must have the XInclude namespace, and a local name of "include".
 protected boolean isRootDocument() 
 protected boolean isTopLevelIncludedItem() 
    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
 protected boolean isTopLevelIncludedItemViaFallback() 
 protected boolean isTopLevelIncludedItemViaInclude() 
 protected Augmentations modifyAugmentations(Augmentations augs) 
    Modify the augmentations. Add an [included] infoset item, if the current element is a top level included item.
 protected Augmentations modifyAugmentations(Augmentations augs,
    boolean force) 
    Modify the augmentations. Add an [included] infoset item, if force is true, or if the current element is a top level included item.
 public  void notationDecl(String name,
    XMLResourceIdentifier identifier,
    Augmentations augmentations) throws XNIException 
 protected XMLAttributes processAttributes(XMLAttributes attributes) 
    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
 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) throws XNIException 
 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) throws XNIException 
 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. 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.
 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]. 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.
 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) throws XMLConfigurationException 
    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.

 protected  void setHref(String href) 
 protected  void setParent(XIncludeHandler parent) 
    Set the parent of this XIncludeHandler in the tree
 public  void setProperty(String propertyId,
    Object value) throws 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.

 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) throws XNIException 
 public  void startCDATA(Augmentations augs) throws XNIException 
 public  void startConditional(short type,
    Augmentations augmentations) throws XNIException 
 public  void startDTD(XMLLocator locator,
    Augmentations augmentations) throws XNIException 
 public  void startDocument(XMLLocator locator,
    String encoding,
    NamespaceContext namespaceContext,
    Augmentations augs) throws XNIException 
    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.
 public  void startElement(QName element,
    XMLAttributes attributes,
    Augmentations augs) throws XNIException 
 public  void startExternalSubset(XMLResourceIdentifier identifier,
    Augmentations augmentations) throws XNIException 
 public  void startGeneralEntity(String name,
    XMLResourceIdentifier resId,
    String encoding,
    Augmentations augs) throws XNIException 
 public  void startParameterEntity(String name,
    XMLResourceIdentifier identifier,
    String encoding,
    Augmentations augmentations) throws XNIException 
 public  void textDecl(String version,
    String encoding,
    Augmentations augs) throws XNIException 
 public  void unparsedEntityDecl(String name,
    XMLResourceIdentifier identifier,
    String notation,
    Augmentations augmentations) throws XNIException 
 public  void xmlDecl(String version,
    String encoding,
    String standalone,
    Augmentations augs) throws XNIException