On the bright side, the text is well written, showing step by step instructions how to proceed with coding in each autonomous chapter. Each code snippet is explained line by line. Some basics of xpath and xquery are presented as well. What is surprising is an introduction to Berkeley DB XML in chapter 13: Storing XML in Oracle Berkeley DB XML. One can find more information on the internet documentation. For a comparison of Oracle Berkeley DB and relational database systems, refer to 'A Comparison of Oracle Berkeley DB and Relational Database Management Systems'. As far as trying the book source code is concerned, in chapter 6 about JSTL XML tag library, the code example runs in the Glassfish, but not in the Weblogic application server; probably due to an older library version than xalan-j_2_7_1 jar. Needless to say there were incompatibilities found: the windows version does not run as is, in windows 7 64 bit, it needs rebuilding via a C++ IDE such as .Net; the embebded weblogic server does not start after setting up the Berkeley DB XML: I quote:
Berkeley DB XML requires some Windows environment variables (CLASSPATH and PATH) to be modified. The following Oracle Berkeley DB XML JAR files get added to the CLASSPATH environment variable:
C:\Program Files\Oracle\Berkeley DB XML 2.4.13\jar\dbxmlexamples.jar;
C:\Program Files\Oracle\Berkeley DB XML 2.4.13\jar\dbxml.jar;
C:\Program Files\Oracle\Berkeley DB XML 2.4.13\jar\db.jar
The following bin directory gets added to the PATH environment variable:
C:\Program Files\Oracle\Berkeley DB XML 2.4.13\bin
On the dark side, the book is rather old, some code about converting XML to excel spreadsheets via poi in chapter12 for example, is deprecated, the version of the Oracle Berkeley DB mentioned is 2.4.13 and so on. No errata page is available on the internet. Moreover, it is unusual to find in a java class source file, two or more classes defined together, as in the following code snippet for DOM3Filter.java:
package dom3ls;
import org.w3c.dom.*;
import org.w3c.dom.ls.*;
import oracle.xml.parser.v2.*;
import org.w3c.dom.traversal.*;
import java.io.*;
public class DOM3Filter {
public void filter() {
try {
DOMImplementationLS impl = new XMLDOMImplementation();
LSParser parser =
impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS,
null);
InputFilter inputFilter = new InputFilter();
parser.setFilter(inputFilter);
Document document =
parser.parseURI("file://c:/DOM3.0/catalog.xml");
LSSerializer domWriter = impl.createLSSerializer();
OutputFilter outputFilter = new OutputFilter();
domWriter.setFilter(outputFilter);
LSOutput lsOutput = impl.createLSOutput();
OutputStream outputStream =
new FileOutputStream(new File("filter-output.xml"));
lsOutput.setByteStream(outputStream);
domWriter.write(document, lsOutput);
} catch (IOException e) {
System.out.println("IOException " + e.getMessage());
}
catch (DOMException e) {
System.out.println("DOMException " + e.getMessage());
}
}
public static void main(String[] args) {
DOM3Filter dom3Filter = new DOM3Filter();
dom3Filter.filter();
}
private class InputFilter implements LSParserFilter {
public short acceptNode(Node node) {
return NodeFilter.FILTER_ACCEPT;
}
public int getWhatToShow() {
return NodeFilter.SHOW_ALL;
}
public short startElement(Element element) {
System.out.println("Element Parsed " + element.getTagName());
return NodeFilter.FILTER_ACCEPT;
}
}
private class OutputFilter implements LSSerializerFilter {
public short acceptNode(Node node) {
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)node;
if (element.getTagName().equals("journal"))
if (element.getAttribute("date").equals("May-June 2008"))
return NodeFilter.FILTER_REJECT;
}
return NodeFilter.FILTER_ACCEPT;
}
public int getWhatToShow() {
return NodeFilter.SHOW_ALL;
}
}
}
All in all, the book is rather old, but its structured, step by step approach makes it a good introduction to processing XML. The vast majority of its source code is more or less reusable.Thus, it could serve well as an introduction to XML.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.