Java and XSLT By Eric M. Burke The unconfirmed error reports are from readers. They have not yet been approved or disproved by the author or editor and represent solely the opinion of the reader. 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 This page was updated November 20, 2002. UNCONFIRMED errors and comments from readers: [2] fig 1.1; Database component should appear on the right and Web browser should appear on the right. {2} Figure 1.1; The flow on the figure is incorrect. XML Data should be coming from the Database - not the Web Browser! HTML output should be going to the Web Browser - not the Database! {21-23} Example 1-5; Change all addAttribute() to setAttribute(). Same errors [addAttribute()]in downloaded source code LibraryJDOMCreator.java. Source code for class LibraryJDOMCreator also have extra brackets "(" at lines 58,59,66 and 68. (30) end of "SAXON" section; On the command line to transform the presidents.xml file, the stylesheet is named "presidents.xslt". There is no such file in the examples. Works fine with "presidentsToCSV.xslt". [31] 5th paragraph on browser plug-ins; I would like a web site or list of browser plug-ins that currently exist that support XSLT. I have a Linux machine running Netscape 6.2, which seems to work with XSLT. I do most of my work on my iMac and using IE 5.1 on Mac OS X does not have MSXML available. I am willing to use another browser if I could find one that works. Maybe even a list of web browsers and how to get them to work with XSLT in a development environment as that would be very helpful. I may try using Opera next on my iMac to see if it works. {31} 4th paragraph on Netscape; Netscape 6.2 supports XSLT to some extent as I can load XML files directly in the browser and they work to some extent. (40) 2nd Paragraph; Under "Trying It Out", the text tells the reader to add "erces.jar" to their classpath. This should probably be "xerces.jar" {40} Paragraph: trying it out; intead of "chap 1" there should be chap 2 Printing date: Sept 2001 (50) near top (html tag); The xmlns attribute of the html tag should be moved to the xsl:stylesheet tag (where the xsl namespace is defined). Otherwise, some of the tags in the output won't have a namespace; and, therefore, the page will not be rendered correctly in some browsers (i.e Mozilla). {50} line 15 in source for schedule.xslt containing " When I create the schedule.xhtml by using the following java command and loading it into any web browser it works correctly: $ java -classpath /home/rick/xerces/xercesImpl.jar:/home/rick/javaxslt/lib/xalan_2.1.jar:/home/rick/javaxslt/lib/jaxp_1.1.jar:/home /rick/javaxslt/lib/jdom_beta6.jar org.apache.xalan.xslt.Process -IN schedule.xml -XSL schedule.xslt > schedule.xhtml {50} line 15 in source for schedule.xslt containing " should point to the one listed on page 57 as Example 2-8: [60] 1st paragraph; The XPath expression //name selects all name descendants of the *root node*, not of the context node as stated. .//name selects all name descendants of the context node {64} paragraph; The chap2/links.xslt does not matching the book and it generates invalid HTML: http://www.amazon.com/exec/obidos/ASIN/ It produces links with spaces and tabs in them which never work: XML Pocket Reference The code work if changes to match the book contents of: http://www.amazon.com/exec/obidos/ASIN/ (69) Example 3-1 (continued) line 26; Typo: The line is ' disable-output-escaping="yes">' but should: ''. (71) example continued - top of page line 1; Typo: The line is ' disable-output-escaping="yes">' but should: ''. {77} 4th paragraph; missing the line in the Example 3-3 namedTemplate.xslt. The example code downloaded in the ZIP file has the line but it is missing in the book. It should be the first line at the top of page 77, in Example 3-3 namedTemplate.xslt (continued). (83) Example 3-7 lines 12 and 23; Typo: The line is ' disable-output-escaping="yes">' but should: '' [95] Example 3-12; When I create the resulting XSLT file I see a formatting difference that is strange. It seems like the following lines are not processing correctly when using indent="yes": When I run the following command: java -classpath /home/rick/xerces/xercesImpl.jar:/home/rick/javaxslt/lib/xalan_2.1.jar:/home/rick/javaxslt/lib/jaxp_1.1.jar:/home/r ick/javaxslt/lib/jdom_beta6.jar org.apache.xalan.xslt.Process -IN log.xml -XSL schemaChange.xslt > result.xslt I see the following lines in result.xslt: input parameter was null For some reason the line before timestamp has TABs in it and the line does not. This is a minor point, but I am trying to le arn and understand XSLT so I can use it on a major project I am working on. {155} Middle Figure 5-3; Figure 5-3 on the right side it depicts the JAXP Result interface. It subclasses this with a DOMResult, StreamResult, and SAXResult. Under the StreamResult java.io.File, java.io.InputStream, and java.io.Reader are specified. These are incorrect. Since it is a Result interface these should be java.io.File, java.io.OutputStream, and java.io.Writer. (174) Example 5-9 line 24; Typo: The line reads ' disable-output-escaping="yes">' but shound read ''. {179} Figure 5-6; At bottom of the figure, there is a space missing in the text and should be "Many users/threads can share". [Example 5.7] CSVXMLReader.java; Not sure what's changed but with the current version of Xalan (2.4.1) the CSVXMLReader needs modification. It runs fine with one argument to produce straight xml. However if you run it with the xslt as the second arg the only output you get is a blank table. I managed to get things to work by changing the calls to startElement() and endElement() : Was : ch.startElement("","","csvFile",EMPTY_ATTR); Becomes: ch.startElement("","csvFile","csvFile",EMPTY_ATTR); Similarly: ch.endElement("","","csvFile"); Becomes ch.endElement("","csvFile","csvFile"); Repeated for calls on "line" and "value". BTW not sure if you know but a very similar csv parser is apparently authored by Matt Liotta http://archive.devx.com/java/free/articles/ml040802/ml040802-1.asp I can't see any acknowledgement to your work in his article which I think is most unprofessional on his part. (191) 1st paragraph; jar -cvfM ../appname.war should be jar -cvfM ../appname.war * A minor typo, but it caused some puzzling error messages and took me about an hour of work to sort out - luckily I had another servlets book that had the answer. (271) MySQL dump; I understand that MySQL table names are case sensitive under Unix. I am running Redhat Linux 7.1. The file discussion/design/mysql_forum_dump.txt uses lower case for table names, but the Java source code uses mixed case for the table names. I imported the text file to generate the tables, and this caused errors when running the forum app to the effect that the table did not exist. Changing the text file to use mixed case tables names and then recreating the database solved the problem. {example code} This is a problem with the example presidents.xml file in the examples. It points to an xslt file that doesn't exist: when i open in Internet Explorer I get this error: The system cannot locate the object specified. Error processing resource 'file://C:\xslt\javaxslt_examples_02Sep2001\javaxslt\chapters\chap9\stress.xslt'. Tried searching all the files, but none appears. i downloaded the zip version. (507) middle of second column; The page number for the index item "XML to XML" under "transformations" should read "91" rather than "90".