Package com.ibm.di.parser
Class XMLParser
- java.lang.Object
-
- com.ibm.di.parser.ParserImpl
-
- com.ibm.di.parser.XMLParser
-
- All Implemented Interfaces:
ParserInterface
,VersionInfoInterface
,org.xml.sax.ErrorHandler
- Direct Known Subclasses:
DSMLParser
,SOAPParser
public class XMLParser extends ParserImpl implements org.xml.sax.ErrorHandler
A class reading and writing Entries in XML format.
-
-
Field Summary
Fields Modifier and Type Field Description org.w3c.dom.NodeList
children
The children of the document element of the input Documentint
curindex
Variable containing the current indexjavax.xml.parsers.DocumentBuilder
db
The document builder used to build the documentjava.lang.String
entrytag
The value of the "xmlEntryTag" attributeorg.w3c.dom.Document
inputDoc
If we are reading a document,inputDoc
will be available as the XML DOM object in JavaScriptorg.w3c.dom.Document
outputDoc
If we are writing a document, outputDoc will be available as the XML DOM object in JavaScriptorg.w3c.dom.Element
toplevel
The root elementorg.w3c.dom.Element
toplevelInput
The document element of the input Documentboolean
useCData
Whether using CDATASection or TextNode.java.lang.String
valuetag
The value of the "xmlValueTag" attribute-
Fields inherited from class com.ibm.di.parser.ParserImpl
_debug, myConfiguration
-
-
Constructor Summary
Constructors Constructor Description XMLParser()
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closeParser()
Close the parservoid
error(org.xml.sax.SAXParseException exception)
Rethrows the given exceptionvoid
fatalError(org.xml.sax.SAXParseException exception)
Ignore this since an error is called immediately afterwardsvoid
flush()
Flush any data to the outputboolean
getOmitXMLDeclaration()
Returns whether we omit XML declaration or not.java.lang.String
getVersion()
Version information.void
initInput()
Initializes the properties from the input Documentvoid
initOutput()
Initializes the output Documentvoid
initParser()
This function is called by the connector containing this parserEntry
readEntry()
Constructs the next entry from the data structure read in initially.void
registerScriptBeans(ScriptEngine se)
Registers inputDoc or outputDoc as the XML DOM object in JavaScriptvoid
setOmitXMLDeclaration(boolean omit)
Sets whether to omit XML declaration or not.void
warning(org.xml.sax.SAXParseException err)
Logs the given warningvoid
writeEntry(Entry entry)
Constructs the data structure from the next entry read in initially.-
Methods inherited from class com.ibm.di.parser.ParserImpl
debug, debugMode, getClassInstance, getContext, getDebug, getInputStream, getOutputStream, getParam, getParser, getReader, getWriter, isDeltaSupported, logmsg, querySchema, setConfiguration, setContext, setDebug, setInputStream, setInputStream, setInputStream, setOutputStream, setOutputStream, setParam, setParser
-
-
-
-
Field Detail
-
inputDoc
public org.w3c.dom.Document inputDoc
If we are reading a document,inputDoc
will be available as the XML DOM object in JavaScript
-
outputDoc
public org.w3c.dom.Document outputDoc
If we are writing a document, outputDoc will be available as the XML DOM object in JavaScript
-
toplevel
public org.w3c.dom.Element toplevel
The root element
-
toplevelInput
public org.w3c.dom.Element toplevelInput
The document element of the input Document
-
children
public org.w3c.dom.NodeList children
The children of the document element of the input Document
-
curindex
public int curindex
Variable containing the current index
-
useCData
public boolean useCData
Whether using CDATASection or TextNode. Default is CDATASection
-
entrytag
public java.lang.String entrytag
The value of the "xmlEntryTag" attribute
-
valuetag
public java.lang.String valuetag
The value of the "xmlValueTag" attribute
-
db
public javax.xml.parsers.DocumentBuilder db
The document builder used to build the document
-
-
Method Detail
-
registerScriptBeans
public void registerScriptBeans(ScriptEngine se) throws java.lang.Exception
Registers inputDoc or outputDoc as the XML DOM object in JavaScript- Specified by:
registerScriptBeans
in interfaceParserInterface
- Overrides:
registerScriptBeans
in classParserImpl
- Parameters:
se
- ScriptEngine- Throws:
java.lang.Exception
- if an error occurs.
-
initParser
public void initParser() throws java.lang.Exception
This function is called by the connector containing this parser- Specified by:
initParser
in interfaceParserInterface
- Overrides:
initParser
in classParserImpl
- Throws:
java.lang.Exception
- if an error occurs.
-
closeParser
public void closeParser() throws java.lang.Exception
Close the parser- Specified by:
closeParser
in interfaceParserInterface
- Overrides:
closeParser
in classParserImpl
- Throws:
java.lang.Exception
- if an error occurs.
-
flush
public void flush() throws java.lang.Exception
Flush any data to the output- Specified by:
flush
in interfaceParserInterface
- Overrides:
flush
in classParserImpl
- Throws:
java.lang.Exception
- if an error occurs.
-
initOutput
public void initOutput() throws java.lang.Exception
Initializes the output Document- Throws:
java.lang.Exception
- If could not find output stream.
-
initInput
public void initInput() throws java.lang.Exception
Initializes the properties from the input Document- Throws:
java.lang.Exception
- if no input stream is found.
-
readEntry
public Entry readEntry() throws java.lang.Exception
Constructs the next entry from the data structure read in initially. If end of data encountered a null value is returned.- Specified by:
readEntry
in interfaceParserInterface
- Returns:
- the next Entry
- Throws:
java.lang.Exception
- if an error occurs.
-
writeEntry
public void writeEntry(Entry entry) throws java.lang.Exception
Constructs the data structure from the next entry read in initially.- Specified by:
writeEntry
in interfaceParserInterface
- Parameters:
entry
- the next Entry- Throws:
java.lang.Exception
- if an error occurs.
-
setOmitXMLDeclaration
public void setOmitXMLDeclaration(boolean omit)
Sets whether to omit XML declaration or not.- Parameters:
omit
- iftrue
omits XML declaration header in output stream; otherwise does not omit XML declaration;
-
getOmitXMLDeclaration
public boolean getOmitXMLDeclaration()
Returns whether we omit XML declaration or not.- Returns:
true
if omits XML declaration header in output stream;false
otherwise.
-
fatalError
public void fatalError(org.xml.sax.SAXParseException exception)
Ignore this since an error is called immediately afterwards- Specified by:
fatalError
in interfaceorg.xml.sax.ErrorHandler
- Parameters:
exception
-SAXParseException
-
error
public void error(org.xml.sax.SAXParseException exception) throws org.xml.sax.SAXException
Rethrows the given exception- Specified by:
error
in interfaceorg.xml.sax.ErrorHandler
- Parameters:
exception
-SAXParseException
- Throws:
org.xml.sax.SAXException
-
warning
public void warning(org.xml.sax.SAXParseException err) throws org.xml.sax.SAXException
Logs the given warning- Specified by:
warning
in interfaceorg.xml.sax.ErrorHandler
- Parameters:
err
- SAXParseException- Throws:
org.xml.sax.SAXException
-
getVersion
public java.lang.String getVersion()
Version information.- Specified by:
getVersion
in interfaceVersionInfoInterface
- Returns:
- version information
-
-