Hi,

Other people may have raised their ears in expectation, so I am going to
give away the most essential details anyway.. ;-)

You need to create a new Java Cocoon component unfortunately. The
easiest way is to extend the AbstractTextSerializer. You basically only
need to overrule the setOutputStream function to create a transform
handler and register that as content handler. Something like:

                        SAXTransformerFactory tfactory =
this.getTransformerFactory();
                        Templates templates = tfactory.newTemplates(new
StreamSource(xslURI));
                        TransformerHandler transformerHandler =
tfactory.newTransformerHandler(templates);

        
transformerHandler.getTransformer().setOutputProperties(this.format);
                        transformerHandler.setResult(new
StreamResult(this.output));
                        
                        this.setContentHandler(transformerHandler);
                        this.setLexicalHandler(transformerHandler);

xslURI is a parameter that could be passed to the component by using the
configure interface (creation of object), or perhaps even through setup
interface (preparation of sitemap, perhaps more convenient).

The java code of XMLSerializer has pretty much everything you need,
except that it doesn't lookup this xslURI variable and it doesn't create
a new TransformerHandler each time as it isn't applying any XSL..

Also make sure to add the following parameter to the map:serializer
definition and also something to specify the XSL containing the
character maps:

        
<transformer-factory>net.sf.saxon.TransformerFactoryImpl</transformer-fa
ctory>

If you google for 'XSLSerializer', you will find lots of comments of
some other people having created similar things. (Found no real code
though.) The general conclusion is to keep the serializer clean, so just
add stuff in the XSL that cannot be put in an XSL transform before...

Anyhow, I have extended the AbstractTextSerializer for other uses as
well. It really takes a large step to create a first component of
yourselves, but once that is behind you... ;-)

Kind regards,
Geert

PS: I am not able to share the real code, for copyrights reasons.
Sorry.. :-(

> -----Original Message-----
> From: Heather Rankin [mailto:[EMAIL PROTECTED] 
> Sent: maandag 9 juni 2008 17:01
> To: users@cocoon.apache.org
> Subject: RE: character-maps in cocoon
> 
> Hi Geert,
> 
> Just to save you some digging, I managed to get this working with the
> saxon:parse() extension instead. This works fine (no need for 
> character
> maps):
> 
> <!-- Where <node> contains text mixed with enity references 
> --> <xsl:copy-of select="saxon:parse(results/node)"/>
> 
> Thanks for the help.
> 
> Heather
> 
> -----Original Message-----
> From: Geert Josten [mailto:[EMAIL PROTECTED]
> Sent: 09 June 2008 11:46
> To: users@cocoon.apache.org
> Subject: RE: character-maps in cocoon
> 
> Heather,
> 
> This could be done by using Saxon as (XSL)Serializer. I have 
> some code around somewhere, but I won't be able to look it up 
> till the end of the day (CET time).
> 
> Kind regards,
> Geert
> 
> > 
>   
>  
> Drs. G.P.H. Josten
> Consultant
>  
>  
> http://www.daidalos.nl/
> Daidalos BV
> Source of Innovation
> Hoekeindsehof 1-4
> 2665 JZ Bleiswijk
> Tel.: +31 (0) 10 850 1200
> Fax: +31 (0) 10 850 1199
> http://www.daidalos.nl/
> KvK 27164984
> De informatie - verzonden in of met dit emailbericht - is 
> afkomstig van Daidalos BV en is uitsluitend bestemd voor de 
> geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen, 
> verzoeken wij u het te verwijderen. Aan dit bericht kunnen 
> geen rechten worden ontleend.
>  
> 
> > From: Jeroen Reijn [mailto:[EMAIL PROTECTED]
> > Sent: maandag 9 juni 2008 12:38
> > To: users@cocoon.apache.org
> > Subject: Re: character-maps in cocoon
> > 
> > Hi!
> > 
> > You could try to use disable-output-escaping in your xslt 
> files. Maybe
> 
> > that will help.
> > 
> > Regards,
> > 
> > Jeroen
> > 
> > 
> > Heather Rankin wrote:
> > > Hi,
> > > 
> > > Are character-maps supported in Cocoon 2.1? I need to
> > replace &lt; and
> > > &gt; entity references with the literal characters '<' 
> and '>' and 
> > > can't get it to work in Cocoon. I have the following
> > character-map in my XSLT:
> > > 
> > > <xsl:output use-character-maps="cm1" method="xml" indent="yes"
> > > encoding="UTF-8" media-type="text/xml"/>
> > >   
> > > <xsl:character-map name="cm1">
> > >   <xsl:output-character character="&lt;" string="&lt;"/>
> > >   <xsl:output-character character="&gt;" string="&gt;"/> 
> > > </xsl:character-map>
> > > 
> > > This works fine outside of cocoon (e.g. in Oxygen). But
> > when I run it
> > > through the second transformer in the following pipleline:
> > > 
> > > <map:match pattern="terms">
> > >   <map:generate src="{request-param:url}" type="html"/>
> > >   <map:transform type="xslt2" src="transforms/getTerms.xsl"/>
> > >   <map:transform type="xslt2"
> > > src="transforms/convertStringToXML.xsl"/>
> > >   <map:serialize type="xml"/>
> > > </map:match>
> > > 
> > > ... the &lt; and &gt; characters do not get replaced
> > (remain escaped).
> > > Is this something to do with the xml serializer? Do I need
> > to change
> > > something there?
> > > 
> > > Heather
> > > 
> > > http://www.bbc.co.uk/
> > > This e-mail (and any attachments) is confidential and may
> > contain personal views which are not the views of the BBC unless 
> > specifically stated.
> > > If you have received it in error, please delete it from 
> your system.
> > > Do not use, copy or disclose the information in any way nor
> > act in reliance on it and notify the sender immediately.
> > > Please note that the BBC monitors e-mails sent or received.
> > > Further communication will signify your consent to this.
> > >                                   
> > > 
> > > 
> > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
>  
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> http://www.bbc.co.uk/
> This e-mail (and any attachments) is confidential and may 
> contain personal views which are not the views of the BBC 
> unless specifically stated.
> If you have received it in error, please delete it from your system.
> Do not use, copy or disclose the information in any way nor 
> act in reliance on it and notify the sender immediately.
> Please note that the BBC monitors e-mails sent or received.
> Further communication will signify your consent to this.
>                                       
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to