[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: how to translate XML with XHTML-formatted element

Subject: Re: how to translate XML with XHTML-formatted element to FO
From: Alex Milowski <alexml@xxxxxxxxxxxx>
Date: Tue, 12 Apr 2005 18:14:30 -0700
how to translate trademark
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>&lt;b&gt;Donald Duck - &lt;i&gt;The True Story&lt;/i&gt;
&lt;/b&gt;</TITLE>
 </BOOK>

 <BOOK>
   <AUTHOR>Matt Groening</AUTHOR>
   <PRICE>25.00</PRICE>
   <TITLE>&lt;b&gt;Homer Simpson For President&lt;/b&gt;</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>&lt;b&gt;Homer Simpson For President&lt;/b&gt;</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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.