Python & XML By Christopher A. Jones & Fred L. Drake, Jr. This errata page lists errors outstanding in the most recent printing. If you have technical questions or error reports, you can send them to booktech@oreilly.com. Please specify the printing date of your copy. This page was updated October 13, 2003 Here's a key to the markup: [page-number]: serious technical mistake {page-number}: minor technical mistake : important language/formatting problem (page-number): language change or minor formatting problem ?page-number?: reader question or request for clarification Confirmed errors: *** p. 23 -- paragraph under "Physical Structures" -- change second sentence to: "Entities are identified in various ways, but most commonly by filename or uniform resource identifier (URI)." (25) 5th full paragraph (Under "The ASCII character set" heading); In the second sentence the word "ever" should be replaced with the word "every". ASCII is understood by virtually ever computer in use. should be: ASCII is understood by virtually every computer in use. (33) 3rd full paragraph; In the second sentence the word "on" should be replaced with the word "of". ...processing instruction is entirely a matter on convention; the... should say: ...processing instruction is entirely a matter of convention; the... (36) 6th paragraph; The first sentence, which begins with "We can break up the declaration in particular systactic components..." should read: "We can break up the declaration into particular syntactic components..." (52) code example at the bottom of the page; In the last line of the element replace the word "exhibition" with the word "expedition." {53} -- first code snippet -- change the following: ------------------------------------------------------------------------ # - ArticleHandler (add to handlers.py file) class ArticleHandler(ContentHandler): """ A handler to deal with articles in XML """ ------------------------------------------------------------------------ to this: ------------------------------------------------------------------------ from xml.sax.handler import ContentHandler class ArticleHandler(ContentHandler): """A handler to deal with articles in XML""" ------------------------------------------------------------------------ *** p. 54 -- Remove the following line of output from the top of the page: Start element: title *** p55, Example 3-3, first line: Change "XML.sax.handler" to "xml.sax.handler" (all lower case). {56} last output paragraph ; The body part of the outpur from the art.py program is too long. It should end after "completed " because self.body=self.body[:78]+ "...". If you also used the spacing indentation in the article.xml example the body part text should stop at "NASA has com" *** No change required for reprint. But for confirmed errata page say: The exact end of the text will depend on the specific indentation used in the article.xml file, as well as whether the indentation uses space or tab characters. *** p. 57-58 -- All double-underscores "__" in code and prose should have a hair-space between the underscores. Would it be possible to search all of Chapter 3 for this and fix all of them? *** p60, Example 3-4. 9th line on page: "def __init__(..." should be indented two spaces. *** p68, Example 3-6, replace the first 11 lines: ------------------------------------------------------------------------ from xml.sax import ContentHandler class SAXThumbs(ContentHandler): """ This is the SAX handler that generates a full- image display (an .html page) for each image file contained in the XML file. It also adds an anchor on the thumbs page showing the thumbnail, and linking to the big image page that was created first. ------------------------------------------------------------------------ with these 11 lines: ------------------------------------------------------------------------ import os from xml.sax import ContentHandler class SAXThumbs(ContentHandler): """ This is the SAX handler that generates a full-image display (an .html page) for each image file contained in the XML file. It also adds an anchor on the thumbs page showing the thumbnail, and linking to the big image page that was created first. *** p68, Example 3-6, last 5 lines on page should be replaced with: ------------------------------------------------------------------------ fullImageFile = os.path.join(dir, localname[2:]) + ".html" print "Will create:", fullImageFile fullImageHTML = ('\n' % (localname[2:], ext)) ------------------------------------------------------------------------ Please keep all lines at current indentation. *** p75, Example 3-9, startElement() method: The "print" statement should be commented out; change: print "* Processing:", s to: # print "* Processing:", s Please maintain same indentation of line as we have now. *** p. 98 -- fix the 2 "__" on this page by inserting hair spaces. *** p. 100 -- fix the 2 "__" on this page by inserting hair spaces. *** p153, command line example at bottom of page, first line should be: C:\>python c:\python20\xmldoc\demo\xmlproc\xvcmd.py order.xml In other words, change "$ " at beginning of line to "C:\>" *** p155, new_element_type() method, replace: ------------------------------------------------------------------------ def new_element_type(self, elem_name, elem_cont): print "New Element Type Declaration: ", elem_name, \ "Content Model: ", elem_cont ------------------------------------------------------------------------ with: ------------------------------------------------------------------------ def new_element_type(self, elem_name, elem_cont): print "New Element Type Declaration: ", elem_name print "Content Model: ", elem_cont *** p168, command line example in the middle of the page should be: C:\pythonxml\c7>python val.py BillSummary.xml In other words change "c6" to "c7" *** p173, Example 7-14, 3/4 of the way down the page, the line: flatfile = query.getvalue("flatfile", "")[0] should be: flatfile = query.getvalue("flatfile", "") In other words, drop the "[0]" at the end. Please maintain the same indentation. *** p174, Example 7-14, near the end, the line: if veh.errors: should read: if hasattr(veh, "errors") and veh.errors: {sample code - retrive.py} the line - print " of " + totalsize should be print " of ", totalsize {178} 3rd paragraph following Business Process and Modeling; U of UML is the initial of "Unified". *** p193, Example 8-4, halfway down the page, change: req = HTTP("192.168.1.23") # change to your IP or localhost to: req = HTTP("127.0.0.1") # change to a different IP if needed (205) last sentence of 1st paragraph; Duplicate word "shared". p. 233 -- paragraph under "Getting Profiles" -- change last sentence to read: In a simple test case (in the file runcp.py), you could use the methods as follows: p. 233 -- command line at bottom of the page -- change from: G:\pythonxml\c9>python runcp.py to: G:\pythonxml\c10> python runcp.py (236) Last sentence of 1st paragraph; Extra "you": "...the order you in which you..." p. 239 -- first code example -- the line "else:" is out-dented by one space; it should be moved right one space so that "else:" lines up with "if e is not None:" *** p244, Example 10-2, 1/3 of the way down the page, change: raise exception.Exceptions("SQL Exec failed.") to: raise Exception("SQL Exec failed.") Please maintain current indentation of line. p. 261 -- code example at the top of the page (cont. from previous page) -- "if(dom):" should be changed to simply "if dom:" (no change to alignment) *** p. 266-267 -- fix the various "__" on these pages by inserting hair spaces. (268) Line -2 in Example 10-11; Typo in print statement: "Reponse: " should be: "Response: " (269) top; resonse should be response (271) 6th line from the bottom resonse should be response *** p273, Example 10-12, echoResponse() method, near bottom of page, change: self.wfile.write("Body:
") to: self.wfile.write('</xml></font><font face="arial,verdana,helvetica"' ' size="4">Body:<br><xmp>') Please maintain current indentation of lines. *** p285, Example 10-15, halfway down the page, change: id = CustProfElement.getAttributeNS('', "id") to: id = CustProfElement.getAttributeNS(None, "id") Please maintain current indentation of line. (291) 3rd line in 2nd paragraph; their should be there *** p. 294 -- fix the various "__" on this page by inserting hair spaces.