HTML-convert does not print br tags correctly

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

HTML-convert does not print br tags correctly

Ralf Jung
Hi list,

half a year ago, I reported the issue that html serialization converts <br/>
to <br></br> which is, under some circumstances, rendered as <br><br> by many
browsers (see http://orbeon-forms-ops-users.24843.n4.nabble.com/xforms-output-
with-mediatype-quot-text-html-quot-duplicating-br-tags-td3043312.html ). Eric
wrote that something related to this was fixed in the nightly builds, which I
however did not test back then.
In the mean time, I updated to Orbeon 3.9 and slightly changed the way this
code is generated: The output element in the website says

<xf:output mediatype="text/html" ref="instance('content-instance')"
class="item"/>

That instance is filled by a submission, which refers to a pipeline that uses
the following code to generate the actual output:

        <!-- convert data to a serialized document -->
        <p:processor name="oxf:html-converter">
                <p:input name="config">
                        <config>
                                <encoding>utf-8</encoding>
                        </config>
                </p:input>
                <p:input name="data" href="#html"/>
                <p:output name="data" id="serialized"/>
        </p:processor>
        <!-- put the serialized data into our own root element (without an
xs:type), so that output does not re-convert it back to XML -->
        <p:processor name="oxf:xslt">
                <p:input name="data" href="#serialized"/>
                <p:input name="config">
                        <content xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xsl:version="2.0"><xsl:value-of select="."/></content>
                        <!-- the replace fixes br tags, which are sent as <br></br> to
confuse browsers -->
                </p:input>
                <p:output name="data" ref="data"/>
        </p:processor>

The XSLT transformation is unfortunately necessary as otherwise, the code
sending the pipeline output to XForms will recognize the XML structure as
serialized XML and convert it back to plain XML.
Unfortunately, however, this pipeline shows exactly the behaviour I described
back then: <br> tags are rendered duplicated by the browser. Only if I change
the XSLT transformation to

<content xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xsl:version="2.0"><xsl:value-of select="replace(., '&lt;/br&gt;',
'')"/></content>

Output will work correctly. If I change this back to the old way (doing the
serialization in XForms), the same problem occurs.
Am I doing something wrong, or is the bug actually still present?

Kind regards,
Ralf Jung


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: HTML-convert does not print br tags correctly

Tambet Matiisen
I was able to reproduce this problem under 3.9 final. The test case is
attached. If you view it under Firefox, everything is OK. But under IE
the space between first and second line is bigger, which is caused by
<br></br>.

NB! The problem does not occur, when the XHTML namespace is default
namespace.

Regards
Tambet

On 1.06.2011 17:04, Ralf Jung wrote:

> Hi list,
>
> half a year ago, I reported the issue that html serialization converts<br/>
> to<br></br>  which is, under some circumstances, rendered as<br><br>  by many
> browsers (see http://orbeon-forms-ops-users.24843.n4.nabble.com/xforms-output-
> with-mediatype-quot-text-html-quot-duplicating-br-tags-td3043312.html ). Eric
> wrote that something related to this was fixed in the nightly builds, which I
> however did not test back then.
> In the mean time, I updated to Orbeon 3.9 and slightly changed the way this
> code is generated: The output element in the website says
>
> <xf:output mediatype="text/html" ref="instance('content-instance')"
> class="item"/>
>
> That instance is filled by a submission, which refers to a pipeline that uses
> the following code to generate the actual output:
>
> <!-- convert data to a serialized document -->
> <p:processor name="oxf:html-converter">
> <p:input name="config">
> <config>
> <encoding>utf-8</encoding>
> </config>
> </p:input>
> <p:input name="data" href="#html"/>
> <p:output name="data" id="serialized"/>
> </p:processor>
> <!-- put the serialized data into our own root element (without an
> xs:type), so that output does not re-convert it back to XML -->
> <p:processor name="oxf:xslt">
> <p:input name="data" href="#serialized"/>
> <p:input name="config">
> <content xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xsl:version="2.0"><xsl:value-of select="."/></content>
> <!-- the replace fixes br tags, which are sent as<br></br>  to
> confuse browsers -->
> </p:input>
> <p:output name="data" ref="data"/>
> </p:processor>
>
> The XSLT transformation is unfortunately necessary as otherwise, the code
> sending the pipeline output to XForms will recognize the XML structure as
> serialized XML and convert it back to plain XML.
> Unfortunately, however, this pipeline shows exactly the behaviour I described
> back then:<br>  tags are rendered duplicated by the browser. Only if I change
> the XSLT transformation to
>
> <content xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xsl:version="2.0"><xsl:value-of select="replace(., '&lt;/br&gt;',
> '')"/></content>
>
> Output will work correctly. If I change this back to the old way (doing the
> serialization in XForms), the same problem occurs.
> Am I doing something wrong, or is the bug actually still present?
>
> Kind regards,
> Ralf Jung


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

brtest.xhtml (674 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re: HTML-convert does not print br tags correctly

Ralf Jung
Hi,

> I was able to reproduce this problem under 3.9 final. The test case is
> attached. If you view it under Firefox, everything is OK. But under IE
> the space between first and second line is bigger, which is caused by
> <br></br>.
That's weird - I am using Firefox, and the issue I described happens with both
Firefox and Rekonq (a WebKit-based browser). However, at least when I first
experienced the issue, it would show up only if there was also a <a
href="">bla</a> link in the converted XML.

> NB! The problem does not occur, when the XHTML namespace is default
> namespace.
I am always using XHTML as default namesapce (since I have had some weird
issues where, if the XSLT produces XML with a dedicated XHTML namespace, and
this is mixed with XHTML as default namesapce, it would not work properly).

Kind regards,
Ralf


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws