cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "J.Pietschmann" <j3322...@yahoo.de>
Subject Re: Embedded html in xml tags converting to pdf
Date Wed, 30 Jul 2003 21:31:58 GMT
Tim Bachta wrote:
> 
> <message-text>null&lt;P
> toUpdate="1"&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt;:&lt;/P&gt;
> &lt;P&gt;This is a test note.&amp;nbsp; It links to &lt;A
> href="http://www.kopent.com/vyzo"&gt;http://www.kopent.com/vyzo&lt;/A&gt
> ;&lt;/P&gt;
> &lt;P&gt;&amp;nbsp;&lt;/P&gt;
> 									
> </message-text>

As expected. You'll have to do some reparsing. Because a lot
of people subscribed to the bad idea of putting marked up text
into DB strings and similar unfitting containers, you'll find
some hints in the list archive.

Once you managed to get the text into proper XML, simply define
templates for P, STRONG and A which re-serialize the elemen and
add the desired representation:

  <xsl:template match="P">
    &lt;P&gt;<xsl:apply-templates/>&lt;/P&gt;
  </xsl:template match="P">

  <xsl:template match="STRONG">
    &lt;STRONG&gt;<fo:wrapper text-weigth="bold">
     <xsl:apply-templates/>
     </fo:wrapper>&lt;/P&gt;
  </xsl:template match="P">

etc. If you have more elements like P which don't require processing
beyond serializing, you can generalize the template (your homework).

Alternatively, get Saxon 7, install it as your XSLT processor
(could be as easy as removing the Xalan jar and adding the Saxon
jar to WEB-INF/lib), then do use Saxon's extension function for parsing
text as XML, roughly like
  <xsl:template match="message-text">
    <xsl:apply-templates select="saxon:parse(.)" mode="embedded"/>
  </xsl:templates>
Look up the exact function name and related issues in the Saxon docs.
Not that this will bail out on non-well formed XML, for example on the
&nbsp; in your sample, you probably have to double escape ampersands
in the XSP.
Use the templates sketched out above, but add mode="embedded" to
all templates and apply-templates.

I still wonder why so many people have such a difficult time describing
their problems so that others can actually understand it. Why didn't you
mention that you insert a string with marked up text ("tags" in your
language) in your XSP, even after explicitly asked?

J.Pietschmann



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message