Errata

Perl and XML

Errata for Perl 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
Other Digital Version N/A
N/A

Example file ex02_capitalizer.pl has for line 13:

my $cust_xml = XMLin('./customers.xml', forcearray=>1);

and it should be:

my $cust_xml = XMLin('./ex01_spamdoc.xml', forcearray=>1);

Either that or change the example file name to customers.xml.

Edward Hooper  Feb 04, 2013 
Other Digital Version Downloaded Example Code, CH3, ex02_parser.pl
Line 12, 14

Downloaded Code:
use XML::Parser;

my $xmlfile = shift @ARGV; # the file to parse

# initialize parser object and parse the string
my $parser = XML::Parser->new( ErrorContext => 2 );
eval { $parser->parsefile( $xmlfile ); };

# report any error that stopped parsing, or announce success
if( $@ ) {
$@ =~ s/at \/.*?$//s; # remove module line number
print STDERR "\nERROR in '$file':\n$@\n";
} else {
print STDERR "'$file' is well-formed\n";
}

In line 12,14
Change $file to $xmlfile

Arnold Guerin  Dec 27, 2013 
Printed Page 1
"... known as UTF-8. This encoding uses between one and six bytes ..."

In Nov. 2003, RFC 3629 changed this to between one and four bytes.

Anonymous   
Printed Page 1
"... up to a maximum of six bytes."

As of Nov. 2003, this was reduced to a maximum of four bytes.

Anonymous   
Printed Page 1
2.6 Unicode, Character Sets, and Encodings

Sorry, I'm reading it online, so I don't know the page number, but here's the URL:

http://safari.oreilly.com/main.asp?bookname=9780596002053&snode=24

"It's possible to write an entire document in 1-byte characters and have it be
indistinguishable from ISO Latin-1 (a humble address block with addresses ranging
from 0 to 255)"

I don't think that's true. While lower ASCII is identical with UTF8, higher ASCII

Anonymous   
Printed Page 2
"... if that address is greater than 255."

Should be "if that address is greater than 127."

Anonymous   
Printed Page 2
"Several centuries from now, [[page 65]] after Earth begrudgingly joins the

Galactic Friendship Union ... bytes four through six will come in quite handy."

No longer applies, since bytes 5 and 6 are no longer legal for UTF-8.

Anonymous   
Printed Page 3
"It's possible to write an entire document in 1-byte characters and have it be

indistinguishable from ISO Latin-1 ..."

Only if the characters chosen are lower than 0x7f (or 127 decimal).
For more details, see http://en.wikipedia.org/wiki/UTF-8 and
http://en.wikipedia.org/wiki/Latin-1

Anonymous   
PDF Page 3
example 1-1


In this first example
input and perl-generated output are both
missed xml - stylesheet definitions.
Absent of stylesheet in xml is not acceptable by Firefox,
its just print warning and view contents of xml.

Anonymous  Sep 04, 2009 
PDF Page 17
Example 2-2. A document using namespaces

PLS advise/help ..
Cant get reasonable results of perl_xml examples.
On my browser I see xml files and/or perl generated xml pages just
like one long plain-text line.
Few details:
Linux suse-11
Browser firefox 3.0.10

tcshell  Sep 22, 2009 
Printed Page 22
4th paragraph

Anonymous   
Printed Page 26
1st ELEMENT example

Unbalanced parenthesis, probably want:
<!ELEMENT sandwich (((

Anonymous   
Printed Page 46
Example 3-4. An XML datafile

All <fname> tags in this example incorrectly end with </name>

Anonymous   
Printed Page 46
United States

A minor quibble however the example 3-4 XML file is not "well formed". Here is the XML file ex04_datafile.xml as in the book:

<preferences>
<font role="console">
<fname>Courier</name>
<size>9</size>
</font>
<font role="default">
<fname>Times New Roman</name>
<size>14</size>
</font>
<font role="titles">
<fname>Helvetica</name>
<size>10</size>
</font>
</preferences>

Please note that it has the tag <fname>...</name>.

Aforesaid file should be:
<preferences>
<font role="console">
<fname>Courier</fname>
<size>9</size>
</font>
<font role="default">
<fname>Times New Roman</fname>
<size>14</size>
</font>
<font role="titles">
<fname>Helvetica</fname>
<size>10</size>
</font>
</preferences>


Thanks. Though it was a good example file to use on ex01_dumbparser.pl.

Anonymous  Feb 05, 2013 
Printed Page 64-65
last paragraph

Anonymous   
Printed Page 92
Bottom code example, second line

I believe

<doctype book [

should read

<!DOCTYPE book [

Anonymous   
Printed Page 96
last line

"use XML::Handler::Subs" should be terminated with a semi-colon.

Anonymous   
Printed Page 97
sub start_document

I find that
SUPER::start_document()
generates an error "Undefined subroutine &SUPER::start_document"
whereas replacing it with
my $self = shift;
$self->SUPER::start_document();
works.

Anonymous   
Printed Page 97
top

the line:
use XML::Parser::PerlSax
is duplicated from the bottom of page 96

Anonymous   
Printed Page 97
sub_characters

$self->in_element( 'h1' )
should read
$self->within_element( 'h1' )

since in_element tests for the current innermost element, which in the critical case
of "big" (in the example) is "em", whereas what is required is to test whether we are
at any level within an h1.

Incidentally, despite an existing erratum, I find that the line also works without
the quotes around h1:
print $data if( $self->within_element( h1 ));

Anonymous   
Printed Page 111
Example 5-9

In sub end_element,

print "<", $data->{Name}, ">
";

should be changed to

print "</", $data->{Name}, ">
";

(This explains the erroneous output shown at the top of page 109, previously
submitted as an errata by another reader.)

Anonymous   
Printed Page 128-255
is not. Just to let you know ...

{snode 56} Example 5-7;
Missing semicolon on line 2 of the script.

Currently:
use XML::Handler::Subs

Should be:
use XML::Handler::Subs;

[snode 56] Example 5-7;
Start document subroutine dies with the error "Undefined subroutine
&SUPER::start_document called at safari.pl line 26.".

Currently:
sub start_document {
SUPER::start_document( );
print "Summary of file:
";
}

Should read:
sub start_document {
$self = shift;
$self->SUPER::start_document( );
print "Summary of file:
";
}

Anonymous   
Printed Page 143
middle page

"acestor's" is misspelled (ancestor's)

Anonymous   
Printed Page 144
sub is_element

return value == 1 s.b. ELEMENT_NODE?

There is no discussion of the constants included w/ the xml packages, so the actual
name is a guess.

Anonymous   
Printed Page 144
Example 8-2

The example will not work without including the XML::DOMIterator package. Assuming
that a reader uses the downloadable examples, adding a

use ex01_iter;

line at the top of the program will work. This also requires that

1;

be added to the very end of the ex01_iter.pm package.

Anonymous   
Printed Page 145
Example 8-3

Running example 8-3 returns the following message:

this function is obsolete!
It was disabled in version 1.54

My version of XML::LibXML is 1.58, the most current at the time of this submission.
Further investigation has found that iterator() is the offending function and has
been deprecated.

Anonymous   
Printed Page 150
last line on the page, the result of the example.

>grabber.pl data.xml
"//*[@id='104']/parent::*/child::*[2]/name[not(@style='latin')]/node()"
Poison Sumac

The result of this example should be Speckled Alder, not Poison Sumac

This error also occurs on page 151, 1st paragraph, last line.

Specifying @id='222' will produce a result of Poison Sumac.

Anonymous   
Printed Page 153
Section: The Origin of XSLT

"XSLT stands for XML Style Language: Transformations. The name means that it's a
component of the XML Style Language (XSL), assigned to handle the task of converting
input XML into a special format called XSL-FO..."

should be changed to

"XSLT stands for Extensible Stylesheet Language Transformations. The name means that
it's a component of the XML Stylesheet Language (XSL), assigned the task of
expressing style sheets."

Anonymous   
Printed Page 155
last code segment

The recurring s/amp/amp error - wouldn't 'tr' be a better way of doing this?

Anonymous   
Printed Page 164
first line

You shouldn't modify 'unique', RSS is either not unique or it is, 'not very unique'
could be not uncommon, not unusual, not surprising etc.

Anonymous   
Printed Page 165
3 code comment line

printed not pronted

Anonymous   
Printed Page 169
First paragraph

From the text: "This example isn't very interesting, but it looks good in print....
(modulo the whitespace that YAWriter inserted to make things more human-readable)."

A test of this example script yielded XML without added whitespace. In order to get
the desired effect, I had to add the following lines after the YAWriter constructor:

$ya->{'Pretty'} = { PrettyWhiteIndent => 1,
PrettyWhiteNewline => 1};

This works with v0.23 of XML::Handler::YAWriter.

Anonymous   
Printed Page 169
Third paragraph

From the text: "CPAN has many of these modules to choose from, DBD::MySQL,..."

could be changed to

"CPAN has many of these modules to choose from, including DBD::MySQL, ..."

The current verbiage could be interpreted as stating that there are only three DBD
modules available. Thankfully, this is not the case.

Anonymous   
Printed Page 175
XML Example

<?XML Version="1.0">

should be

<?XML Version="1.0"?>

Also,

<monkey-list>
<monkey>
<description xmlns:mm="http://www.jmac.org/projects/monkeys/mm/">

Should probably be

<monkey-list xmlns:mm="http://www.jmac.org/projects/monkeys/mm/">
<monkey>
<description>

As originally written, the XML causes the following error when processed using the
example at the bottom of page 183:

Undefined namespace prefix
xmlXPathCompiledEval: evaluation failed

Anonymous   
Printed Page 179
1st code example

my $parser = XML::ComicsML::Parser->new;

should it not be?

my $parser = XML::ComicsML->new;

Anonymous   
Printed Page 180
sub rebless method

Comment should read

# Define a hash ...

Anonymous   
Printed Page 184
Code example

The line:

print "</ul>
";

should precede the final line of code:

print end_html;

Anonymous   
Printed Page 184
code at top of page

I think the line

my $parser = XML::XPath;

ought to be

my $parser = new XML::LibXML;

or

my $parser = XML::LibXML->new;

It doesn't look like XML::Xpath is used anywhere, but if it were, it would still need a "new".

***SAFARI ONLINE***

Anonymous