Package org.cdlib.mrt.utility
Class DOMParser
java.lang.Object
org.cdlib.mrt.utility.DOMParser
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
convertNodeToString
(Node node) Convert node to stringstatic Document
doParse
(InputStream istream, LoggerInf logger) parse xml contained from input stream InputStream Contains logger param Logger Logger to receive messages, if anystatic Document
doParse
(InputStream istream, LoggerInf logger, boolean validate, boolean nsAware, boolean expandEntities) parse xml contained from input stream InputStream Contains loggerstatic Element
getFirstNode
(Element elem, String name) Stub method: Return first decendant element matching a specific string name (xpath=name[1]static Element
getFirstNode
(Element elem, String name, LoggerInf logger) Return first decendant element matching a specific string name (xpath=name[1] Contains loggerstatic NodeList
getNodeList
(Node node, String expression, LoggerInf logger) Same as above, fewer parameters Logging routine not added since the original code for this method did no have a "throw" in the catch (TransformerException te) which indicates that it may not be worth logging.static String
getSimpleElementText
(Node node, LoggerInf logger) Return concatinated string text values for all text nodes that are children of this node Contains loggerstatic TransformerFactory
static DocumentBuilder
get parser Contains logger
-
Constructor Details
-
DOMParser
public DOMParser()
-
-
Method Details
-
getSimpleElementText
Return concatinated string text values for all text nodes that are children of this node Contains logger- Parameters:
elem
- base element to extract text nodesLogger
- Logger to receive messages, if any- Returns:
- string containing concatinated text nodes
- Throws:
TException
-
doParse
parse xml contained from input stream InputStream Contains logger param Logger Logger to receive messages, if any- Returns:
- root element node for DOM
- Throws:
TException
-
doParse
public static Document doParse(InputStream istream, LoggerInf logger, boolean validate, boolean nsAware, boolean expandEntities) throws TException parse xml contained from input stream InputStream Contains logger- Parameters:
istream
- input stream to be parsedlogger
- framework log for outputvalidate
- flag - true=require xml validation, false=don'tnsAware
- flag - true=force name space awareness, false=don't- Returns:
- root element node for DOM
- Throws:
TException
-
setup
public static DocumentBuilder setup(LoggerInf logger, boolean validate, boolean nsAware, boolean expandEntities) throws TException get parser Contains logger- Parameters:
Logger
- Logger to receive messages, if any- Returns:
- true=setup worked false=exception
- Throws:
TException
-
getNodeList
public static NodeList getNodeList(Node node, String expression, LoggerInf logger) throws TException Same as above, fewer parameters Logging routine not added since the original code for this method did no have a "throw" in the catch (TransformerException te) which indicates that it may not be worth logging.- Parameters:
node
- org.w3c.dom.Node to start with within a document (including a SOAP message)String
- XPath expression to evaluate- Returns:
- nodeList List of nodes that fit the expression
- Throws:
TException
-
getFirstNode
Stub method: Return first decendant element matching a specific string name (xpath=name[1]- Parameters:
elem
- starting element to begin decendant node extractionname
- of child node to be matched- Returns:
- first element matching name
- Throws:
TException
-
getFirstNode
Return first decendant element matching a specific string name (xpath=name[1] Contains logger- Parameters:
elem
- starting element to begin decendant node extractionname
- of child node to be matchedLogger
- Logger to receive messages, if any- Returns:
- first element matching name
- Throws:
TException
-
convertNodeToString
Convert node to string- Parameters:
node
- Node to be converted- Returns:
- String
- Throws:
TransformerException
-
getXalanTransformer
-