First of all, I know nothing about Xalan.

The following article in the JavaWorld Forums:

http://www.javaworld.com/javaworld/jw-04-2006/jw-0410-html.html

explains how to convert HTML to PDF by using JTidy, Xalan and Apache FOP.
The steps are as follows:
1) HTML -> XHTML uing jtidy-04aug2000r7-dev
2) XHTML -> XML-FO using xalan-j 2.7.0
3) XML-FO -> PDF using Apache fop-0.20.5

My problem is that Xalan does not seem to be working.

I am using Windows XP, and I have these packages installed in
c:\downloads\utils\jtidy-04aug2000r7-dev
c:\downloads\utils\xalan-j_2_7_0
c:\downloads\utils\fop-0.20.5
(All binary distributions; I did not compile them myself)
Java 1.6 JRE (1.6.0_03) in C:\program files\java\jre1.6.0_03
Java 1.6 JDK (1.6.0_03) in C:\program files\java\jdk1.6.0_03

xhtml2fo.xsl is an XML stylesheet for converting the output of JTidy to
XML-FO. This stylesheet is supplied with the article.


Following the instructions in the article, I ran the following commands:
java -cp c:\downloads\utils\jtidy-04aug2000r7-dev\Tidy.jar -asxml \
  hello.html> temp.xml

java -cp \
  c:\downloads\utils\xalan-j_2_7_0\xalan.jar\
  ;c:\downloads\utils\xalan-j_2_7_0\xercesImpl.jar\
  ;c:\downloads\utils\xalan-j_2_7_0\xml-apis.jar\
  ;c:\downloads\utils\xalan-j_2_7_0\serializer.jar\
  org.apache.xalan.xslt.Process -TT -TG -TS -TTC -IN temp.xml\
  -XSL xhtml2fo.xsl -OUT temp.fo 
c:\downloads\utils\fop-0.20.5\fop.bat temp.fo hello.pdf

Of course, I did not really use the "\" character. Each command is on
one line, with no unnecessary white space.


JTidy produces the following XML file:




Hello World


Hello World!



This seems to be OK.

The console output of xalan is:
null Line #0, Column #0: template match='/' 
file:///C:/Downloads/Utils/html2pdf/xhtml2fo.xsl Line #0, Column #0: 
apply-templates
Selected source node '#document', at file 
'file:///C:/Downloads/Utils/html2pdf/temp.xml', line #-1, column #-1
(default root rule) apply-templates, select='null': 
     10001: html
null Line #0, Column #0: template match='*' 
file:///C:/Downloads/Utils/html2pdf/xhtml2fo.xsl Line #0, Column #0: 
apply-templates
Selected source node 'html', at file 
'file:///C:/Downloads/Utils/html2pdf/temp.xml', line #-1, column #-1
(default rule) apply-templates, select='null': 
     10004: #text
     10005: head
     1000e: #text
     1000f: body
     10014: #text
STARTDOCUMENT
CHARACTERS: 

null Line #0, Column #0: template match='*' 
file:///C:/Downloads/Utils/html2pdf/xhtml2fo.xsl Line #0, Column #0: 
apply-templates
Selected source node 'head', at file 
'file:///C:/Downloads/Utils/html2pdf/temp.xml', line #-1, column #-1
(default rule) apply-templates, select='null': 
     10006: #text
     10007: meta
     1000a: #text
     1000b: title
     1000d: #text
CHARACTERS: 

null Line #0, Column #0: template match='*' 
file:///C:/Downloads/Utils/html2pdf/xhtml2fo.xsl Line #0, Column #0: 
apply-templates
Selected source node 'meta', at file 
'file:///C:/Downloads/Utils/html2pdf/temp.xml', line #-1, column #-1
(default rule) apply-templates, select='null': 
     [empty node list]
CHARACTERS: 

null Line #0, Column #0: template match='*' 
file:///C:/Downloads/Utils/html2pdf/xhtml2fo.xsl Line #0, Column #0: 
apply-templates
Selected source node 'title', at file 
'file:///C:/Downloads/Utils/html2pdf/temp.xml', line #-1, column #-1
(default rule) apply-templates, select='null': 
     1000c: #text
CHARACTERS: Hello World
CHARACTERS: 

CHARACTERS: 

null Line #0, Column #0: template match='*' 
file:///C:/Downloads/Utils/html2pdf/xhtml2fo.xsl Line #0, Column #0: 
apply-templates
Selected source node 'body', at file 
'file:///C:/Downloads/Utils/html2pdf/temp.xml', line #-1, column #-1
(default rule) apply-templates, select='null': 
     10010: #text
     10011: p
     10013: #text
CHARACTERS: 

null Line #0, Column #0: template match='*' 
file:///C:/Downloads/Utils/html2pdf/xhtml2fo.xsl Line #0, Column #0: 
apply-templates
Selected source node 'p', at file 
'file:///C:/Downloads/Utils/html2pdf/temp.xml', line #-1, column #-1
(default rule) apply-templates, select='null': 
     10012: #text
CHARACTERS: Hello World!
CHARACTERS: 

CHARACTERS: 

ENDDOCUMENT

I do not understand any of this, but all those lines with line #-1,
column #-1 cannot be good. The resulting file is:




Hello World


Hello World!

This is obviously wrong.

The article supplied a file Html2Pdf.java, which is supposed to be the
equivalent of the sequence of commands. I compiled it, and it works.

What am I doing wrong?
_________________________________________________________________
Help yourself to FREE treats served up daily at the Messenger Café. Stop by 
today.
http://www.cafemessenger.com/info/info_sweetstuff2.html?ocid=TXT_TAGLM_OctWLtagline

Reply via email to