public class IfsXmlParser extends DefaultHandler implements Parser
The main function of the parser is to determine the nature of the XML document it is processing, then select the appropriate content-specific parser and submit the document for processing by that parser.
As such, the parser provides for the transparent processing of iFS-specific XML documents, meaning those XML documents that are used to create iFS objects and configure iFS, as well as non-iFS XML documents that are meant to be simply stored in iFS, with or without validation.
The parser uses a PropertyBundle called XmlParserLookup to find the appropriate parser, then instantiates it. If the parser determines the document to be an iFS-specific XML document, it instantiates the standard iFS parser. Otherwise, the parser looks for a custom parser and instantiates that instead. Finally, the parser will look for a parser that would simply create a literal iFS document from the XML document.
The parser can create a DOM tree from the XML document, if required. It uses
the Oracle DOM parser to create the DOM. The content-specific parsers
instantiated by the parser can get the DOM by calling createDOM
.
The parser object is passed to the content-specific parsers for this purpose.
The parser implements the Parser interface, while the content-specific parsers instantiated by the parser implement the XmlParserInterface.
Modifier and Type | Field and Description |
---|---|
static String |
CUSTOM_PARSER
The name associated with the registered custom parser, in the property
bundle containing the class path of registered parsers.
|
static String |
DEFAULT_DTD_VALIDATION
The name associated with the default DTD validation option, in
the property bundle containing the class path of registered parsers.
|
static String |
DEFAULT_NAMESPACE
The name associated with the default namespace, in the property
bundle containing the class path of registered parsers.
|
static String |
DTD_NAME
The key associated with the DTD found by preparsing
|
static String |
LITERAL_DOCUMENT_PARSER
The name associated with the registered literal document parser, in
the property bundle containing the class path of registered parsers.
|
protected Hashtable |
m_PreParseElements
Hashtable for holding interesting objects encountered during pre-parsing
|
protected boolean |
m_RoundtripEnabled
Boolean indicating whether Roundtrip functionality has been enabled
|
protected LibrarySession |
m_Session
The LibrarySession which constructed this XmlParser
|
static String |
OBJECT_LIST_TAG
The tag which specificies a collection of objects
|
static String |
PARSER_PROPERTYBUNDLE
The name of the property bundle containing the class path of registered
parsers.
|
static String |
ROOT_ELEMENT
The key associated with the root element type found by preparsing
|
static String |
ROUNDTRIP_ENABLED
The property name associated with the boolean indicating whether
Roundtrip functionality is enabled, in the property bundle
containing the class path of registered parsers.
|
static String |
SIMPLE_USER_TAG
The tag which specificies creation of a user through UserManager
|
CURRENT_NAME_OPTION, CURRENT_PATH_OPTION, DOCUMENT_CHARSET_OPTION, DOCUMENT_LANGUAGE_OPTION, LITERAL_DOCUMENT_OPTION, UPDATE_OBJECT_OPTION, VALIDATE_DOCUMENT_OPTION
Constructor and Description |
---|
IfsXmlParser(LibrarySession session)
Constucts an IfsXmlParser
|
Modifier and Type | Method and Description |
---|---|
Document |
createDOM(InputStream stream,
boolean validate)
Creates the DOM object from an InputStream, using the Oracle DOM Parser.
|
Document |
createDOM(Reader reader,
boolean validate)
Creates the DOM object from a Reader, using the Oracle DOM Parser.
|
boolean |
isRoundtripEnabled()
Returns true if Roundtrip functionality is enabled, false otherwise.
|
LibraryObject |
parse(InputStream stream,
ParserCallback callback,
Hashtable options)
Inherited from Parser
|
LibraryObject |
parse(Reader reader,
ParserCallback callback,
Hashtable options)
Inherited from Parser
|
void |
setDoctype(String dtdName)
Handles the event that occurs when the SAX parser encounters the DTD
declaration in an XML document during pre-parsing.
|
void |
startElement(String name,
Attributes atts)
Handles the event that occurs when the SAX parser encounters the Root
Element in an XML document during pre-parsing.
|
characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning
public static final String PARSER_PROPERTYBUNDLE
public static final String CUSTOM_PARSER
public static final String LITERAL_DOCUMENT_PARSER
public static final String DEFAULT_DTD_VALIDATION
public static final String DEFAULT_NAMESPACE
public static final String ROUNDTRIP_ENABLED
public static final String ROOT_ELEMENT
public static final String DTD_NAME
public static final String OBJECT_LIST_TAG
public static final String SIMPLE_USER_TAG
protected Hashtable m_PreParseElements
protected boolean m_RoundtripEnabled
protected LibrarySession m_Session
public IfsXmlParser(LibrarySession session)
session
- the LibrarySessionpublic final LibraryObject parse(InputStream stream, ParserCallback callback, Hashtable options) throws IfsException
parse
in interface Parser
stream
- the InputStreamcallback
- an application object that interacts with the
the parsing process; optional, can be nulloptions
- any Parser-specific optionsIfsException
- (IFS-12601) if the operation failspublic final LibraryObject parse(Reader reader, ParserCallback callback, Hashtable options) throws IfsException
parse
in interface Parser
reader
- the Readercallback
- an application object that interacts with the
the parsing process; optional, can be nulloptions
- any Parser-specific optionsIfsException
- (IFS-12602) if the operation failspublic boolean isRoundtripEnabled() throws IfsException
IfsException
- thrown if the operation failspublic Document createDOM(InputStream stream, boolean validate) throws IfsException
stream
- the InputStream representing the XML documentvalidate
- boolean indicating whether the DOM parser should be
used in validating or non-validating modeIfsException
- thrown if the operation failspublic Document createDOM(Reader reader, boolean validate) throws IfsException
reader
- the Reader representing the XML documentvalidate
- boolean indicating whether the DOM parser should be
used in validating or non-validating modeIfsException
- thrown if the operation failspublic void setDoctype(String dtdName) throws SAXException
The DTD name, which follows "
dtd
- Name holds the name of the Document Type Definition information encountered
in the XML document.SAXException
- if an error occurspublic void startElement(String name, Attributes atts) throws SAXException
Once the event occurs, we are no longer interested in continuing the pre-parsing with the SAX parser. So we throw to stop the SAX parser, and place the Root Element's name in the hashtable for subsequent use.
name
- holds the type (name) of the Root Element as well
as namespace information about the Root Elementatts
- holds any attributes associated with the Root ElementSAXException
- if an error occursCopyright © 2023. All rights reserved.