org.inria.ns.reflex.xml.dom
Class DOMFragmentParser

java.lang.Object
  extended by org.inria.ns.reflex.xml.dom.DOMFragmentParser

public class DOMFragmentParser
extends Object

DOMFragmentParser build a document fragment from an XML fragment source that has not necessary a unique root element, or that may have text content around the root element(s).

The XML fragment mustn't contain DTD stuff : it must be a pure mix of XML tags and/or text. Entity resolution is thus irrelevant.

The fragment may begin with a text declaration.

Author:
Philippe Poulard
See Also:
SAXFragmentParser, DOMAdaptableParser

Constructor Summary
DOMFragmentParser(ParserConfiguration configuration)
          Create a parser that parses XML fragments.
 
Method Summary
static DocumentFragment adaptFragment(DocumentFragment fragment)
          In RefleX, a DocumentFragment must behave like a List.
 DocumentFragment parse(InputSource input)
          Parse an input source.
 void setErrorHandler(ErrorHandler errorHandler)
          The error handler to use.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMFragmentParser

public DOMFragmentParser(ParserConfiguration configuration)
Create a parser that parses XML fragments.

Parameters:
configuration - The non-null configuration expected for the parser.
Method Detail

parse

public DocumentFragment parse(InputSource input)
                       throws SAXException,
                              IOException
Parse an input source.

Parameters:
input - The input to parse.
Returns:
A document fragment that is also a List, that may be empty.
Throws:
SAXException
IOException
See Also:
List

adaptFragment

public static DocumentFragment adaptFragment(DocumentFragment fragment)
In RefleX, a DocumentFragment must behave like a List. If necessary, a new document fragment is supplied.

Parameters:
fragment - The fragment.
Returns:
A fragment that can be cast safely to a List.

setErrorHandler

public void setErrorHandler(ErrorHandler errorHandler)
The error handler to use.

Parameters:
errorHandler - The error handler to use ; may be null.