public class SAXXIncluder
extends java.lang.Object
implements org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler
SAXXIncluder is a simple ContentHandler
that writes its XML document onto an output stream after resolving
all xinclude:include elements.
The only current known bug is that the notation and unparsed entity information items are not included in the result infoset. Furthermore, processing instructions in the DTD are not included. Note that this is only relevant to the source infoset. The DOCTYPE declaration is specifically excluded from included infosets.
I also need to check how section 4.4.3.1 applies for inscope namespaces in included documents. Currently this is not an issue because I only include full documents, but it may become an an issue when XPointer support is added.
There's no XPointer support yet. Only full documents are included.
The xinclude:fallback element is not yet supported.
The parser used to drive this must support the LexicalHandler
interface. It must also provide a Locator object.
These are optional in SAX, but Xerces-J does support these features.
| Constructor and Description |
|---|
SAXXIncluder(java.io.OutputStream out) |
SAXXIncluder(java.io.OutputStream out,
java.lang.String encoding) |
| Modifier and Type | Method and Description |
|---|---|
void |
characters(char[] ch,
int start,
int length) |
void |
comment(char[] ch,
int start,
int length) |
void |
endCDATA() |
void |
endDocument() |
void |
endDTD() |
void |
endElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qualifiedName) |
void |
endEntity(java.lang.String name) |
void |
endPrefixMapping(java.lang.String prefix) |
void |
ignorableWhitespace(char[] ch,
int start,
int length) |
static void |
main(java.lang.String[] args)
The driver method for the SAXXIncluder program.
|
void |
processingInstruction(java.lang.String target,
java.lang.String data) |
void |
setDocumentLocator(org.xml.sax.Locator locator) |
void |
setFilter(XIncludeFilter filter) |
void |
skippedEntity(java.lang.String name) |
void |
startCDATA() |
void |
startDocument() |
void |
startDTD(java.lang.String name,
java.lang.String publicID,
java.lang.String systemID) |
void |
startElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qualifiedName,
org.xml.sax.Attributes atts) |
void |
startEntity(java.lang.String name) |
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String uri) |
public SAXXIncluder(java.io.OutputStream out,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingExceptionpublic SAXXIncluder(java.io.OutputStream out)
public void setDocumentLocator(org.xml.sax.Locator locator)
setDocumentLocator in interface org.xml.sax.ContentHandlerpublic void startDocument()
throws org.xml.sax.SAXException
startDocument in interface org.xml.sax.ContentHandlerorg.xml.sax.SAXExceptionpublic void endDocument()
throws org.xml.sax.SAXException
endDocument in interface org.xml.sax.ContentHandlerorg.xml.sax.SAXExceptionpublic void startPrefixMapping(java.lang.String prefix,
java.lang.String uri)
throws org.xml.sax.SAXException
startPrefixMapping in interface org.xml.sax.ContentHandlerorg.xml.sax.SAXExceptionpublic void endPrefixMapping(java.lang.String prefix)
throws org.xml.sax.SAXException
endPrefixMapping in interface org.xml.sax.ContentHandlerorg.xml.sax.SAXExceptionpublic void startElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qualifiedName,
org.xml.sax.Attributes atts)
throws org.xml.sax.SAXException
startElement in interface org.xml.sax.ContentHandlerorg.xml.sax.SAXExceptionpublic void endElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qualifiedName)
throws org.xml.sax.SAXException
endElement in interface org.xml.sax.ContentHandlerorg.xml.sax.SAXExceptionpublic void characters(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
characters in interface org.xml.sax.ContentHandlerorg.xml.sax.SAXExceptionpublic void ignorableWhitespace(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
ignorableWhitespace in interface org.xml.sax.ContentHandlerorg.xml.sax.SAXExceptionpublic void processingInstruction(java.lang.String target,
java.lang.String data)
throws org.xml.sax.SAXException
processingInstruction in interface org.xml.sax.ContentHandlerorg.xml.sax.SAXExceptionpublic void skippedEntity(java.lang.String name)
throws org.xml.sax.SAXException
skippedEntity in interface org.xml.sax.ContentHandlerorg.xml.sax.SAXExceptionpublic void startDTD(java.lang.String name,
java.lang.String publicID,
java.lang.String systemID)
throws org.xml.sax.SAXException
startDTD in interface org.xml.sax.ext.LexicalHandlerorg.xml.sax.SAXExceptionpublic void endDTD()
throws org.xml.sax.SAXException
endDTD in interface org.xml.sax.ext.LexicalHandlerorg.xml.sax.SAXExceptionpublic void startEntity(java.lang.String name)
throws org.xml.sax.SAXException
startEntity in interface org.xml.sax.ext.LexicalHandlerorg.xml.sax.SAXExceptionpublic void endEntity(java.lang.String name)
throws org.xml.sax.SAXException
endEntity in interface org.xml.sax.ext.LexicalHandlerorg.xml.sax.SAXExceptionpublic void startCDATA()
throws org.xml.sax.SAXException
startCDATA in interface org.xml.sax.ext.LexicalHandlerorg.xml.sax.SAXExceptionpublic void endCDATA()
throws org.xml.sax.SAXException
endCDATA in interface org.xml.sax.ext.LexicalHandlerorg.xml.sax.SAXExceptionpublic void setFilter(XIncludeFilter filter)
public void comment(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
comment in interface org.xml.sax.ext.LexicalHandlerorg.xml.sax.SAXExceptionpublic static void main(java.lang.String[] args)
The driver method for the SAXXIncluder program. Output is written to System.out.
args - contains the URLs and/or filenames
of the documents to be procesed.Copyright 2002 Jason Hunter, Brett McLaughlin. All Rights Reserved.