Errata

Java and XML

Errata for Java and XML

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page ch 3
has to do with missing info regarding the example online

the online examples for the 3rd edition book are missing many/some sample .xml, .xsd, .dtd files that are referenced in the text;

i found most of what i'm looking for -- have not validated entire book -- by doing both of the following.

the U-R-What box on page 47 -- references a URI/URL -- by investigating this URL -- i found some of the xml, dtd files mentioned in the book but not contained in the examples/samples; no where was it mentioned that it was necessary to actually go to this website to find files mentioned in the book. --see page 48 reference to play.dtd

other places -- for example page 51 where discussing example code for setDocumentLocator -- is not present in the example program for ch3 or any other chapters -- i searched all the examples -- but i did find the referenced code in the examples provided for ch3 for the 1st edition book. also the file contents.xml referenced on page 47 does not exist in the examples for 3rd edition book -- but i did find said file in the 1st edition book samples.

gary bello  May 13, 2009 
Printed Page 25
1st paragraph

There is a url listed to download a version of "Relaxer", an application to transform
an XML document into a DTD or XSD. In fact this url returns "GONE" when accessed.
Here is the specific download url.
http://www.relaxer.jp/download/relaxer-1.0.zip

Anonymous   
29
4th paragraph

"complexType simply informs the schema parser that the element is not a predefined schema type, like string or integer."

You're confusing complexType with complexContent.

Quoting from the book "Definitive XML Schema":

"Elements that have complex types have child elements or attributes.
They may also have character content."

Anonymous  Jan 11, 2010 
Printed Page 35
Example at the top of the page

In the RELAX NG schema for phonebook, I see two consecutive "firstName" elements listed, I think the first element should be "firstName" and the second element should be "middleName" or "lastName". Is my affirmation correct or the example is supposed to be OK?

Abel Morelos  Nov 26, 2009 
Printed Page 45
Second Section - Instantiating a Reader

The sample code provided for Chapter 3 contains the "finished" code for the SAXTreeViewer class. It
includes a reference to a SimpleEntityResolver class. If you try to use the sample code it won't compile
because you don't have this other class.

Turns out the class is defined and discussed in Chapter 4 - but there is no reference to that in the
sample code.

In order to run the Ch 3 sample I had to google the class name (SimpleEntityResolver) and run across the
PDF of Chapter 4 of the book since the class is not mentioned in the book's index either.

Code examples should (IMO) work as provided or have big comments at the top defining what is missing (to
be done) before the code will work.

Anonymous   
Printed Page 46
7 lines from bottom

A method is called that has never been defined:
viewer.init(args[0]);
It is defined in the downloaded examples but even then there are problems in the init method, e.g.:

// Build the tree model
defaultTreeModel = new DefaultTreeModel(base);
jTree = new JTree(defaultTreeModel);

It just seems like book and code were hastily done, based on the three chapters I've read so far.

I've enjoyed it but it's been difficult to get this example to work correctly. It worked well once I did however. Perhaps this was never intended to be a complete working example. But it is about 90% complete so you don't really realize until you're done that parts of the file are missing and only in the downloaded examples.

Anonymous  Aug 15, 2008 
Printed Page 46
Two statements prior to the "catch" block toward the bottom of the page

The statement reads as follows:

viewer.init(args[0]);

There is no "init()" method available.

aspsa  Mar 15, 2009 
Printed Page 82
3rd para++

3rd paragraph says figure 4-5 has sample output -- it does not, it contains a uml diagram.

the 'paw' insert below 3rd paragraph says as_you-with_entity.xml file is contained in examples download; -- not true.

many of examples in this book are not contained in the examples download.

gary bello  May 15, 2009 
Printed Page 127
Line 10

The book source code says:

System.err.println("Usage: java javaxmls.DOMModuleChecker " +
"org.w3c.dom.DOMImplementation impl class");

The correct code should be:

System.err.println("Usage: java javaxmls.DOMModuleChecker " +
"org.apache.xerces.dom.DOMImplementationImpl");

Anonymous   
Printed Page 165
java command example under Changing the Parser Implementation

The command line example having -Djavax.xml.transform.TransformerFactory should be changed to -
Djavax.xml.parsers.SAXParserFactory.

Anonymous   
Printed Page 165
Section "Changing the Parser Implementation"

In the command:

java -Djavax.xml.transform.TransformerFactory=org.apache.xerces.parsers.SAXParser
javaxml3.SAXTester ibm-jaxp-article.xml

both the property name and value are wrong. The entire command should be:

java -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl
javaxml3.SAXTester ibm-jaxp-article.xml

Anonymous   
184
StaticVariableResolver class

The following line declares a class named StaticVariableResolver which implements an interface with the same name:
class StaticVariableResolver implements StaticVariableResolver {

Should be replaced with:
public class StaticVariableResolver implements XPathVariableResolver {

Abel Morelos  Jan 06, 2010 
184
Code fragment at the bottom of the page

The following code line uses a wrong date regarding the way the dates are supposed to be contained in the tds.xml sample file:
xPath.setXPathVariableResolver(new StaticVariableResolver("06.12.2006"));

The correct expression is as follows:
xPath.setXPathVariableResolver(new StaticVariableResolver("06.12.06"));

In the same code fragment, there is a comment preceding the evaluate method call like this:
//this next line throws a NullPointerException

This is misleading, the comments should be removed since the code is supposed to work, seems like teh author made a copy&paste of the code fragment at the top of the same page without removing that comment.

Abel Morelos  Jan 06, 2010 
Printed Page 276
NegateFilter, OrFiler, and AndFilter Sections

org.jdom.filter.NegateFilter, org.jdom.filter.OrFilter, and org.jdom.filter.OrFilter are all protected
methods and cannot be directly instantiated.

The three examples should really be along these lines:

// Create filters that inherit from AbstractFilter
// to get "negate", "and", and "or" methods.
AbstractFilter filter1 = new ElementFilter("person");
AbstractFilter filter2 = new ElementFilter( Namespace.getNamespace("http://jitjat.com/fake") );

// negation of a filter
Filter notFilter1 = filter1.negate();

// or'ing two filters
Filter filter1OrFilter2 = filter1.or( filter2 );

// and'ing of two filters
Filter filter1AndFilter2 = filter1.and( filter2 );

Anonymous   
Printed Page 278
First paragraph

The printed text is:
With this value set to false (the default), you'd get the resolved content. A second serialization might result in:

Correction: The default is true and that is when you get the resolved content.

The following is from JDOM JavaDoc

setExpandEntities
public void setExpandEntities(boolean expand)This sets whether or not to expand entities for the builder. A true means to expand entities as normal content. A false means to leave entities unexpanded as EntityRef objects. The default is true.

When this setting is false, the internal DTD subset is retained; when this setting is true, the internal DTD subset is not retained.



Anonymous  Oct 18, 2010 
Printed Page 289
2nd Paragraph

The default factory class is org.jdom.DocumentFactory. Should be org.dom4j.DocumentFactory.

Also on same page 3rd paragraph: For example, org.jdom.util.IndexedDocumentFactory creates instances of
org.dom4j.util.IndexedElement instead of DefaultElement. This should be
org.dom4j.util.IndexedDocumentFactory.

Anonymous   
Printed Page 295
2nd paragraph of the "Document Output" subsection

While the text states that an XMLWriter writes XML objects to either a java.io.Writer or a
java.io.InputStream, it in fact writes to a java.io.Writer or a java.io.OutputStream.

Anonymous   
Printed Page 296
3rd paragraph from the bottom

A newline is output between the XML declaration and first node of the document if the
newLineAfterDeclaration property is true (rather than false, as stated in the text).

Anonymous   
Printed Page 303
example code at the bottom of the page

Perhaps it might be nicer if the class "NamesapceChangingVisitor" was called "NamespaceChangingVisitor"
instead.

Anonymous   
Printed Page 305
Example 10-3

The variable "out" must be declared as a "DocumentResult", not as a "JDOMResult".

Anonymous   
Printed Page 310
2nd paragraph

The sentence

"Instead, you marshall XML into Java objects and unmarshall Java objects into an XML document."

probably should read

"Instead, you unmarshal XML into Java objects and marshal Java objects into an XML document."

(i.e. 'marshal' and 'unmarshal' have to be interchanged, and they are spelled with one 'l' at the end
only).

Anonymous   
Printed Page 331
Paragraph underneath Example 11-8

"javax.xml.bind.annotations.XmlAccessType" must be "javax.xml.bind.annotation.XmlAccessType".

Anonymous   
Printed Page 438
Section "Unicode Normalization Checking"

The URI: http://xml.org/sax/features/validation

is wrong, should be:

URI: http://xml.org/sax/features/unicode-normalization-checking

Anonymous