On Apr 12, 2005, at 11:12 AM, Magic Finger wrote:
how can I translate XML files (like the following), which contain
XHTML-formatted text in one element, to PDF using Apache FOP ?
--- books.xml --->
<BOOK>
<AUTHOR>Walt Disney</AUTHOR>
<PRICE>19.90</PRICE>
<TITLE><b>Donald Duck - <i>The True Story</i>
</b></TITLE>
</BOOK>
<BOOK>
<AUTHOR>Matt Groening</AUTHOR>
<PRICE>25.00</PRICE>
<TITLE><b>Homer Simpson For President</b></TITLE>
</BOOK>
...
<--- books.xml ---
You can translate the escape XHTML with a XML pipeline as implemented
by the smallx [1] project at java.net:
<p:pipe name="xhtml-convert"
xmlns:p="urn:publicid:IDN+smallx.com:pipeline:1.0"
>
<p:subtree select="TITLE">
<p:parse/>
</p:subtree>
</p:pipe>
That will convert:
<TITLE><b>Homer Simpson For President</b></TITLE>
to:
<TITLE><b xmlns="http://www.w3.org/1999/xhtml">Homer Simpson For
President</b></TITLE>
You can also "trap" parse errors:
<p:pipe name="xhtml-convert"
xmlns:p="urn:publicid:IDN+smallx.com:pipeline:1.0"
>
<p:subtree select="TITLE">
<p:trap>
<p:parse/>
<p:on-error>
<p:template>
<TITLE bad="true"><xsl:copy-of select="/*/node()"/></TITLE>
</p:template>
</p:on-error>
</p:trap>
</p:subtree>
</p:pipe>
[1] http://smallx.dev.java.net
-- Alex Milowski
"The excellence of grammar as a guide is proportional to the paucity of
the
inflexions, i.e. to the degree of analysis effected by the language
considered."
Bertrand Russell in a footnote of Principles of Mathematics
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--