gnu.xml.pipeline
Class XIncludeFilter

java.lang.Object
  |
  +--gnu.xml.pipeline.EventFilter
        |
        +--gnu.xml.pipeline.XIncludeFilter
All Implemented Interfaces:
ContentHandler, DeclHandler, DTDHandler, EventConsumer, LexicalHandler, Locator

public class XIncludeFilter
extends EventFilter
implements Locator

Filter to process an XPointer-free subset of XInclude, supporting its use as a kind of replacement for parsed general entities. XInclude works much like the #include of C/C++ but works for XML documents as well as unparsed text files. Restrictions from the 16-May-2001 draft of XInclude are as follows:

XML documents that are included will normally be processed using the default SAX namespace rules, meaning that prefix information may be discarded. This may be changed with setSavingPrefixes().

TBD: "IURI" handling.

Version:
$Date: 2001/10/25 07:32:04 $
Author:
David Brownell

Field Summary
 
Fields inherited from class gnu.xml.pipeline.EventFilter
DECL_HANDLER, FEATURE_URI, LEXICAL_HANDLER, PROPERTY_URI
 
Constructor Summary
XIncludeFilter(EventConsumer next)
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          SAX2: passes this callback to the next consumer, if any
 void comment(char[] ch, int start, int length)
          SAX2: passes this callback to the next consumer, if any
 void endCDATA()
          SAX2: passes this callback to the next consumer, if any
 void endDocument()
          SAX2: passes this callback to the next consumer, if any
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
          SAX2: passes this callback to the next consumer, if any
 void endEntity(java.lang.String name)
          SAX2: passes this callback to the next consumer, if any.
 void endPrefixMapping(java.lang.String prefix)
          SAX2: passes this callback to the next consumer, if any
 void externalEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          SAX2: passes this callback to the next consumer, if any
 int getColumnNumber()
          Used for proxy locator; do not call directly.
 int getLineNumber()
          Used for proxy locator; do not call directly.
 java.lang.String getPublicId()
          Used for proxy locator; do not call directly.
 java.lang.String getSystemId()
          Used for proxy locator; do not call directly.
 void ignorableWhitespace(char[] ch, int start, int length)
          SAX2: passes this callback to the next consumer, if any
 boolean isSavingPrefixes()
          Returns the flag controlling the setting of the SAX2 namespace-prefixes flag when parsing included documents.
 void processingInstruction(java.lang.String target, java.lang.String value)
          SAX2: passes this callback to the next consumer, if any
 void setDocumentLocator(Locator locator)
          Passes "this" down the filter chain as a proxy locator.
 void setSavingPrefixes(boolean flag)
          Assigns the flag controlling the setting of the SAX2 namespace-prefixes flag.
 void skippedEntity(java.lang.String name)
          SAX2: passes this callback to the next consumer, if any
 void startCDATA()
          SAX2: passes this callback to the next consumer, if any
 void startDocument()
          SAX2: passes this callback to the next consumer, if any
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, Attributes atts)
          SAX2: passes this callback to the next consumer, if any
 void startEntity(java.lang.String name)
          SAX2: passes this callback to the next consumer, if any.
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          SAX2: passes this callback to the next consumer, if any
 
Methods inherited from class gnu.xml.pipeline.EventFilter
attributeDecl, bind, chainTo, elementDecl, endDTD, getContentHandler, getDocumentLocator, getDTDHandler, getErrorHandler, getNext, getProperty, internalEntityDecl, notationDecl, setContentHandler, setDTDHandler, setErrorHandler, setProperty, startDTD, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XIncludeFilter

public XIncludeFilter(EventConsumer next)
               throws SAXException
Method Detail

setDocumentLocator

public void setDocumentLocator(Locator locator)
Passes "this" down the filter chain as a proxy locator.

Specified by:
setDocumentLocator in interface ContentHandler
Overrides:
setDocumentLocator in class EventFilter
Parameters:
locator - An object that can return the location of any SAX document event.
See Also:
Locator

getSystemId

public java.lang.String getSystemId()
Used for proxy locator; do not call directly.

Specified by:
getSystemId in interface Locator
Returns:
A string containing the system identifier, or null if none is available.
See Also:
Locator.getPublicId()

getPublicId

public java.lang.String getPublicId()
Used for proxy locator; do not call directly.

Specified by:
getPublicId in interface Locator
Returns:
A string containing the public identifier, or null if none is available.
See Also:
Locator.getSystemId()

getLineNumber

public int getLineNumber()
Used for proxy locator; do not call directly.

Specified by:
getLineNumber in interface Locator
Returns:
The line number, or -1 if none is available.
See Also:
Locator.getColumnNumber()

getColumnNumber

public int getColumnNumber()
Used for proxy locator; do not call directly.

Specified by:
getColumnNumber in interface Locator
Returns:
The column number, or -1 if none is available.
See Also:
Locator.getLineNumber()

setSavingPrefixes

public void setSavingPrefixes(boolean flag)
Assigns the flag controlling the setting of the SAX2 namespace-prefixes flag.


isSavingPrefixes

public boolean isSavingPrefixes()
Returns the flag controlling the setting of the SAX2 namespace-prefixes flag when parsing included documents. The default value is the SAX2 default (false), which discards information that can be useful.


startDocument

public void startDocument()
                   throws SAXException
Description copied from class: EventFilter
SAX2: passes this callback to the next consumer, if any

Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in class EventFilter
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.endDocument()

endDocument

public void endDocument()
                 throws SAXException
Description copied from class: EventFilter
SAX2: passes this callback to the next consumer, if any

Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in class EventFilter
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.startDocument()

externalEntityDecl

public void externalEntityDecl(java.lang.String name,
                               java.lang.String publicId,
                               java.lang.String systemId)
                        throws SAXException
Description copied from class: EventFilter
SAX2: passes this callback to the next consumer, if any

Specified by:
externalEntityDecl in interface DeclHandler
Overrides:
externalEntityDecl in class EventFilter
Parameters:
name - The name of the entity. If it is a parameter entity, the name will begin with '%'.
publicId - The declared public identifier of the entity, or null if none was declared.
systemId - The declared system identifier of the entity.
Throws:
SAXException - The application may raise an exception.
See Also:
DeclHandler.internalEntityDecl(java.lang.String, java.lang.String), DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)

startEntity

public void startEntity(java.lang.String name)
                 throws SAXException
Description copied from class: EventFilter
SAX2: passes this callback to the next consumer, if any.

Specified by:
startEntity in interface LexicalHandler
Overrides:
startEntity in class EventFilter
Parameters:
name - The name of the entity. If it is a parameter entity, the name will begin with '%', and if it is the external DTD subset, it will be "[dtd]".
Throws:
SAXException - The application may raise an exception.
See Also:
LexicalHandler.endEntity(java.lang.String), DeclHandler.internalEntityDecl(java.lang.String, java.lang.String), DeclHandler.externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)

endEntity

public void endEntity(java.lang.String name)
               throws SAXException
Description copied from class: EventFilter
SAX2: passes this callback to the next consumer, if any.

Specified by:
endEntity in interface LexicalHandler
Overrides:
endEntity in class EventFilter
Parameters:
name - The name of the entity that is ending.
Throws:
SAXException - The application may raise an exception.
See Also:
LexicalHandler.startEntity(java.lang.String)

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         Attributes atts)
                  throws SAXException
Description copied from class: EventFilter
SAX2: passes this callback to the next consumer, if any

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class EventFilter
Parameters:
localName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
qName - The qualified name (with prefix), or the empty string if qualified names are not available.
atts - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String), Attributes

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws SAXException
Description copied from class: EventFilter
SAX2: passes this callback to the next consumer, if any

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class EventFilter
Parameters:
localName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
qName - The qualified XML 1.0 name (with prefix), or the empty string if qualified names are not available.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Description copied from class: EventFilter
SAX2: passes this callback to the next consumer, if any

Specified by:
characters in interface ContentHandler
Overrides:
characters in class EventFilter
Parameters:
ch - The characters from the XML document.
start - The start position in the array.
length - The number of characters to read from the array.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.ignorableWhitespace(char[], int, int), Locator

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String value)
                           throws SAXException
Description copied from class: EventFilter
SAX2: passes this callback to the next consumer, if any

Specified by:
processingInstruction in interface ContentHandler
Overrides:
processingInstruction in class EventFilter
Parameters:
target - The processing instruction target.
value - The processing instruction data, or null if none was supplied. The data does not include any whitespace separating it from the target.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws SAXException
Description copied from class: EventFilter
SAX2: passes this callback to the next consumer, if any

Specified by:
ignorableWhitespace in interface ContentHandler
Overrides:
ignorableWhitespace in class EventFilter
Parameters:
ch - The characters from the XML document.
start - The start position in the array.
length - The number of characters to read from the array.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.characters(char[], int, int)

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws SAXException
Description copied from class: EventFilter
SAX2: passes this callback to the next consumer, if any

Specified by:
comment in interface LexicalHandler
Overrides:
comment in class EventFilter
Parameters:
ch - An array holding the characters in the comment.
start - The starting position in the array.
length - The number of characters to use from the array.
Throws:
SAXException - The application may raise an exception.

startCDATA

public void startCDATA()
                throws SAXException
Description copied from class: EventFilter
SAX2: passes this callback to the next consumer, if any

Specified by:
startCDATA in interface LexicalHandler
Overrides:
startCDATA in class EventFilter
Throws:
SAXException - The application may raise an exception.
See Also:
LexicalHandler.endCDATA()

endCDATA

public void endCDATA()
              throws SAXException
Description copied from class: EventFilter
SAX2: passes this callback to the next consumer, if any

Specified by:
endCDATA in interface LexicalHandler
Overrides:
endCDATA in class EventFilter
Throws:
SAXException - The application may raise an exception.
See Also:
LexicalHandler.startCDATA()

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws SAXException
Description copied from class: EventFilter
SAX2: passes this callback to the next consumer, if any

Specified by:
startPrefixMapping in interface ContentHandler
Overrides:
startPrefixMapping in class EventFilter
Parameters:
prefix - The Namespace prefix being declared.
uri - The Namespace URI the prefix is mapped to.
Throws:
SAXException - The client may throw an exception during processing.
See Also:
ContentHandler.endPrefixMapping(java.lang.String), ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
                      throws SAXException
Description copied from class: EventFilter
SAX2: passes this callback to the next consumer, if any

Specified by:
endPrefixMapping in interface ContentHandler
Overrides:
endPrefixMapping in class EventFilter
Parameters:
prefix - The prefix that was being mapping.
Throws:
SAXException - The client may throw an exception during processing.
See Also:
ContentHandler.startPrefixMapping(java.lang.String, java.lang.String), ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

skippedEntity

public void skippedEntity(java.lang.String name)
                   throws SAXException
Description copied from class: EventFilter
SAX2: passes this callback to the next consumer, if any

Specified by:
skippedEntity in interface ContentHandler
Overrides:
skippedEntity in class EventFilter
Parameters:
name - The name of the skipped entity. If it is a parameter entity, the name will begin with '%', and if it is the external DTD subset, it will be the string "[dtd]".
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.


Source code is under GPL (with library exception) in the JAXP project at http://www.gnu.org/software/classpathx/jaxp
This documentation was derived from that source code on 2003-06-07.