gnu.xml.pipeline

Class XIncludeFilter

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 17-Sept-2002 CR 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(). You are strongly advised to do this.

Note that XInclude allows highly incompatible implementations, which are specialized to handle application-specific infoset extensions. Some such implementations can be implemented by subclassing this one, but they may only be substituted in applications at "user option".

TBD: "IURI" handling.

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(ch[] , int start, int length)
SAX2: passes this callback to the next consumer, if any
void
comment(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(String uri, String localName, String qName)
SAX2: passes this callback to the next consumer, if any
void
endEntity(String name)
SAX2: passes this callback to the next consumer, if any.
void
endPrefixMapping(String prefix)
SAX2: passes this callback to the next consumer, if any
void
externalEntityDecl(String name, String publicId, 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.
String
getPublicId()
Used for proxy locator; do not call directly.
String
getSystemId()
Used for proxy locator; do not call directly.
void
ignorableWhitespace(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(String target, 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(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(String uri, String localName, String qName, Attributes atts)
SAX2: passes this callback to the next consumer, if any
void
startEntity(String name)
SAX2: passes this callback to the next consumer, if any.
void
startPrefixMapping(String prefix, String uri)
SAX2: passes this callback to the next consumer, if any

Methods inherited from class gnu.xml.pipeline.EventFilter

attributeDecl, bind, chainTo, characters, comment, elementDecl, endCDATA, endDTD, endDocument, endElement, endEntity, endPrefixMapping, externalEntityDecl, getContentHandler, getDTDHandler, getDocumentLocator, getErrorHandler, getNext, getProperty, ignorableWhitespace, internalEntityDecl, notationDecl, processingInstruction, setContentHandler, setDTDHandler, setDocumentLocator, setErrorHandler, setProperty, skippedEntity, startCDATA, startDTD, startDocument, startElement, startEntity, startPrefixMapping, unparsedEntityDecl

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

XIncludeFilter

public XIncludeFilter(EventConsumer next)
            throws SAXException

Method Details

characters

public void characters(ch[] ,
                       int start,
                       int length)
            throws SAXException
SAX2: passes this callback to the next consumer, if any
Specified by:
characters in interface ContentHandler
Overrides:
characters in interface EventFilter

comment

public void comment(ch[] ,
                    int start,
                    int length)
            throws SAXException
SAX2: passes this callback to the next consumer, if any
Specified by:
comment in interface LexicalHandler
Overrides:
comment in interface EventFilter

endCDATA

public void endCDATA()
            throws SAXException
SAX2: passes this callback to the next consumer, if any
Specified by:
endCDATA in interface LexicalHandler
Overrides:
endCDATA in interface EventFilter

endDocument

public void endDocument()
            throws SAXException
SAX2: passes this callback to the next consumer, if any
Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in interface EventFilter

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
            throws SAXException
SAX2: passes this callback to the next consumer, if any
Specified by:
endElement in interface ContentHandler
Overrides:
endElement in interface EventFilter

endEntity

public void endEntity(String name)
            throws SAXException
SAX2: passes this callback to the next consumer, if any.
Specified by:
endEntity in interface LexicalHandler
Overrides:
endEntity in interface EventFilter

endPrefixMapping

public void endPrefixMapping(String prefix)
            throws SAXException
SAX2: passes this callback to the next consumer, if any
Specified by:
endPrefixMapping in interface ContentHandler
Overrides:
endPrefixMapping in interface EventFilter

externalEntityDecl

public void externalEntityDecl(String name,
                               String publicId,
                               String systemId)
            throws SAXException
SAX2: passes this callback to the next consumer, if any
Specified by:
externalEntityDecl in interface DeclHandler
Overrides:
externalEntityDecl in interface EventFilter

getColumnNumber

public int getColumnNumber()
Used for proxy locator; do not call directly.
Specified by:
getColumnNumber in interface Locator

getLineNumber

public int getLineNumber()
Used for proxy locator; do not call directly.
Specified by:
getLineNumber in interface Locator

getPublicId

public String getPublicId()
Used for proxy locator; do not call directly.
Specified by:
getPublicId in interface Locator

getSystemId

public String getSystemId()
Used for proxy locator; do not call directly.
Specified by:
getSystemId in interface Locator

ignorableWhitespace

public void ignorableWhitespace(ch[] ,
                                int start,
                                int length)
            throws SAXException
SAX2: passes this callback to the next consumer, if any
Specified by:
ignorableWhitespace in interface ContentHandler
Overrides:
ignorableWhitespace in interface EventFilter

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.

processingInstruction

public void processingInstruction(String target,
                                  String value)
            throws SAXException
SAX2: passes this callback to the next consumer, if any
Specified by:
processingInstruction in interface ContentHandler
Overrides:
processingInstruction in interface EventFilter

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 interface EventFilter

setSavingPrefixes

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

skippedEntity

public void skippedEntity(String name)
            throws SAXException
SAX2: passes this callback to the next consumer, if any
Specified by:
skippedEntity in interface ContentHandler
Overrides:
skippedEntity in interface EventFilter

startCDATA

public void startCDATA()
            throws SAXException
SAX2: passes this callback to the next consumer, if any
Specified by:
startCDATA in interface LexicalHandler
Overrides:
startCDATA in interface EventFilter

startDocument

public void startDocument()
            throws SAXException
SAX2: passes this callback to the next consumer, if any
Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in interface EventFilter

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes atts)
            throws SAXException
SAX2: passes this callback to the next consumer, if any
Specified by:
startElement in interface ContentHandler
Overrides:
startElement in interface EventFilter

startEntity

public void startEntity(String name)
            throws SAXException
SAX2: passes this callback to the next consumer, if any.
Specified by:
startEntity in interface LexicalHandler
Overrides:
startEntity in interface EventFilter

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
            throws SAXException
SAX2: passes this callback to the next consumer, if any
Specified by:
startPrefixMapping in interface ContentHandler
Overrides:
startPrefixMapping in interface EventFilter

XIncludeFilter.java -- Copyright (C) 2001,2002 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.