|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.elharo.xml.xinclude.DOMXIncluder
DOMXIncluder
provides methods to
resolve DOM elements and documents to produce
a new Document
or Element
with all XInclude references resolved.
This program works with Xerces-2. It does not yet work with GNU JAXP. It was working with Crimson but stopped recently. I'm not sure why.
XPointers are not yet supported.
The xinclude:fallback element is not yet supported.
It does not yet handle the merging of unparsed entity and notation information items from the included infosets. Furthermore it does not include the source document's doctype declaration if that contains an internal DTD subset. This may be the result of a Xerces bug.
Field Summary | |
static java.lang.String |
XINCLUDE_NAMESPACE
|
static java.lang.String |
XML_NAMESPACE
|
Method Summary | |
static void |
main(java.lang.String[] args)
The driver method for the XIncluder program. |
static org.w3c.dom.Document |
merge(org.w3c.dom.Document original,
java.lang.String base)
This method resolves a DOM Document
and merges in all XInclude references. |
static org.w3c.dom.DocumentFragment |
merge(org.w3c.dom.Element original,
java.lang.String base)
This method resolves a DOM Element
and merges in all XInclude references. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String XINCLUDE_NAMESPACE
public static final java.lang.String XML_NAMESPACE
Method Detail |
public static org.w3c.dom.Document merge(org.w3c.dom.Document original, java.lang.String base) throws XIncludeException, java.lang.NullPointerException, javax.xml.parsers.ParserConfigurationException
This method resolves a DOM Document
and merges in all XInclude references.
The Document
object returned is a new document.
The original Document
object is not changed.
This method depends on the ability to clone a DOM Document
which not all DOM parsers may be able to do.
It definitely exercises a bug in Xerces-J 1.3.1.
This bug is fixed in Xerces-J 1.4.0 through 1.4.3
but reappears in Xerces-J 1.4.4
Xerces-J 2.0.x can do this.
original
- Document
that will be processedbase
- String
form of the base URI against which
relative URLs will be resolved. This can be null if the
document includes an xml:base
attribute or
does not use relative URLs.
Document
object in which all
XInclude elements have been replaced.
XIncludeException
- if this document, though namespace well-formed,
violates one of the rules of XInclude.
java.lang.NullPointerException
- if the original argument is null.
javax.xml.parsers.ParserConfigurationException
public static org.w3c.dom.DocumentFragment merge(org.w3c.dom.Element original, java.lang.String base) throws MalformedResourceException, XIncludeException, java.lang.NullPointerException, CircularIncludeException, BadParseAttributeException, UnavailableResourceException, MissingHrefException, javax.xml.parsers.ParserConfigurationException
This method resolves a DOM Element
and merges in all XInclude references. This process is recursive.
The DocumentFragment
returned contains no XInclude elements.
If a referenced document cannot be found, an exception is thrown.
The DocumentFragment
object returned is a new element.
The original Element
is not changed.
original
- Element
that will be processedbase
- String
form of the base URI against which
relative URLs will be resolved. This can be null if the
element includes an xml:base
attribute.
MissingHrefException
- if the href
attribute is missing from an include element.
MalformedResourceException
- if an included document is not namespace well-formed
BadParseAttributeException
- if an include
element has a parse
attribute
with any value other than text
or parse
UnavailableResourceException
- if the URL in the include element's
href
attribute cannot be loaded.
CircularIncludeException
- if this Element
contains an XInclude element
that attempts to include a document in which
this element is directly or indirectly included.
java.lang.NullPointerException
- if the original
argument is null.
XIncludeException
javax.xml.parsers.ParserConfigurationException
public static void main(java.lang.String[] args)
The driver method for the XIncluder program. I'll probably move this to a separate class soon.
args
- contains the URL and/or filenames of the
input document and the output filename.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |