Database Reference
In-Depth Information
private String getElementContent(java.io.InputStream
inputStream) throws
javax.xml.parsers.ParserConfigurationException,
org.xml.sax.SAXException,
java.io.IOException {
String elementContent = null;
inElement = false;
SAXParserFactory factory =
SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
SAXParser parser = factory.newSAXParser();
parser.parse(inputStream,this);
if ( stringBuffer.length() > 0 ) elementContent =
stringBuffer.toString();
return elementContent;
}
This SAX parsing routine is pretty standard for all the XML servlets as it's the first step to
map message type/content for further actions. For simple routing actions, this implement-
ation will be sufficient. As a matter of fact, if we want to have a full-fledged Message
Broker with content-based routing, an implementation of the DOM parsing is inevitable, as
shown in the following code:
//In XDIServlet, processRequest
//new: DOM parser.
//Get message DOM using Oracle XDK
XMLDocument msgXdiDOM = helper.getMessageDOM(ack);
//In MessageRequestHelper
public XMLDocument getMessageDOM(Acknowledge ack)
throws ServletException, IOException {
String bodyroot = null;
//declaration for different DOM specs
XMLDocument msgXdiDOM = null;
// Document msgXdiDOM;
...
Search WWH ::




Custom Search