Title: RE: HTML escaping in XML

Ok :)

I can also answer my question.

The trick is to disable output escaping for HTML markup.

I could not disable output escaping by modifing properties in <serializer name="html"/> because only relating property is 'cdata-section-elements'. This property produces CDATA directives (output = <![CDATA[<table><tr><td><b>HTMLInsert</b></td></tr></table>]]>) in the resulting stream, what is not correctly recognized by HTML browser and the content of the page look as follows:

HTMLInsert]]

(]] is not wanted content)

The only way I found is to interleave XSLT transformer in the pipeline like this

        <map:match pattern="rpt/test.html">        
                <map:generate src="" label="content"/>
                <map:transform type="xslt" src="" label="xml"/>
                <map:serialize type="html" label="debug"/>
        </map:match>

In the test.xsl must then be specified disable-output-escaping="yes" on xsl:value-of as follows
       
        <xsl:value-of select="node()" disable-output-escaping="yes" />

Warning!:
If the HTML markup does not conform to XML, next pipeline element must be only serilizer (HTML, Text), because after transforming with test.xsl, the result is no longer valid XML.

For example this will not work:
        <map:match pattern="rpt/test.html">        
                <map:generate src="" label="content"/>
                <map:transform type="xslt" src="" label="xml"/>
                <map:transform type="i18n" label="i18n"/>
                <map:serialize type="html" label="debug"/>
        </map:match>

Michal


> -----Original Message-----
> From: DURDINA Michal [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, November 06, 2003 9:44 AM
> To: [EMAIL PROTECTED]
> Subject: HTML escaping in XML
>
>
> Hello,
> I know this is probably frequently answered problem, but I am
> also sure than you can provide realy fast answer :)
>
> I need to insert HTML markup (as text) in my XSP page and
> expecting the serializer not to escape <,> characters for &lt;&gt;
> What am I doing wrong?
>
> Thank you,
> Michal
>
> Pipeline:
>       <map:match pattern="rpt/test.html">        
>               <map:generate src="" label="content"/>
>               <map:serialize type="html" label="debug"/>
>       </map:match>
>
> XSP:
>       <xsp:logic>
>               // HTMLInsert
>               String hi =
> "<![CDATA[<table><tr><td><b>HTMLInsert</b></td></tr></table>]]>";
>               this.characters(hi);
>       </xsp:logic>
>
>
>
> __________ Informacia od NOD32 1.550 (20031104) __________
>
> Tato sprava bola preverena systemom NOD32 pre Exchange.
> http://www.eset.sk
>
>
>

Reply via email to