Convert XHTML to ODF using Xalan-J only yields first paragraph.
Dominic Jacobssen <[email protected]> Mon, 28 Jun 2010 14:53:47 +0300
| Newsgroups | gmane.text.xml.xalan.java.user |
|---|---|
| Message-ID | <[email protected]> |
Hi all.
(Apologies if anyone gets this twice; I didn't realise the first time
that I probably needed to be subscribed to the list; the blurb at
http://xml.apache.org/xalan-j/contact_us.html wasn't clear on this
point).
Anyway, I'm trying to convert XHTML to ODF using Xalan-J and the XSLT
stylesheets from the xhtml2odt project here:
http://gitorious.org/xhtml2odt
This is my first foray into using XSLT, so I've probably messed up
somewhere, but I'm not sure where, and I was wondering if anyone more
experienced in XSLT and/or Xalan could prod me in the right direction.
Using the input file "in.html" (attached), I can convert to an ODF
node fragment with the *same* stylesheets and the command line
"xsltproc" tool just fine:
xsltproc --output out.xml ~/SCM/xhtml2odt/xsl/xhtml2odt.xsl in.html
generates the file "out.xml" (attached).
The Python script "xhtml2odt.py" from the xhtml2odt project also works
(although it inserts the output into an ODT document, using a
template, instead of just yielding ODF fragments).
However, using the Java file "DemonstrateQuestion.java" (attached), I
get the output shown in "xalanj.xml" (attached). It's a lot more
verbose than the xsltproc output, but importantly, I only get the
first paragraph converted. In other words, stripping out the xmlns
noise, I only get:
<text:p text:style-name="Text_20_body">I am the first paragraph.</text:p>
The Java program is being run with the JVM directive:
-Djavax.xml.transform.TransformerFactory=org.apache.xalan.processor.TransformerFactoryImpl
I think I must be using Xalan incorrectly, but it's all getting a bit confusing.
If anyone could afford any help on this, I'd be ever so grateful.
Cheers,
D
in.html
(text/html, 385 B)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org" />
<title></title>
</head>
<body>
<p>I am the first paragraph.</p>
<p>I am the second paragraph.</p>
</body>
</html>
out.xml
(text/xml, 341 B)
<?xml version="1.0" encoding="utf-8"?>
<text:p xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" text:style-name="Text_20_body">I am the first paragraph.</text:p>
<text:p xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" text:style-name="Text_20_body">I am the second paragraph.</text:p>
DemonstrateQuestion.java
(application/octet-stream, 4.5 KB) - not displayed
xalanj.xml
(text/xml, 1.3 KB)
<text:p xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" text:style-name="Text_20_body">I am the first paragraph.</text:p>