Entities are always escaped in ezxml

Author Message

Gabriel Ambuehl

Saturday 25 March 2006 10:19:33 am

I'm trying to parse XHTML in ezxml and serialize it back to XHTML afterwards:

My code:

        $params= array("ConvertSpecialChars" => false);
        $domTree = $ezxml->domTree( &$data, $params);
        eZDebug::writeNotice($domTree->toString());

The following XHTML fragment is giving me trouble:

<section>
 <p class="xfactbox">aaaaaaaa</p>
  <p>
    a&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aaa
    <br />
    <br />
  </p>
  <p class="xfactbox">
    <span class="xemphasize">aaaaaaaaaa</span>
  </p>
</section>

after serializing it back into a string I get

<?xml version="1.0" encoding="UTF-8"?>
<section>
  <p class="xfactbox">aaaaaaaa</p>
  <p>
    a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aaa
    <br />
    <br />
  </p>
  <p class="xfactbox">
    <span class="xemphasize">aaaaaaaaaa</span>
  </p>
</section>

i.e. the ampersand of the Entity gets escaped itself.

I'm using ezpublish 3.6.6 on php 4.3.10, domxml is installed.

Visit http://triligon.org

Xavier Dutoit

Tuesday 28 March 2006 8:08:01 am

It looks like a bug to me. Any news on that topic ?

X+

http://www.sydesy.com

Gabriel Ambuehl

Tuesday 28 March 2006 11:43:32 am

Yes but it seems to happen during serializing back to text, the dom tree itself is working fine.

Visit http://triligon.org

Xavier Dutoit

Tuesday 28 March 2006 11:06:18 pm

So that's the toString method that doesn't play nicely with & then. Right ?

X+

http://www.sydesy.com

Gabriel Ambuehl

Wednesday 29 March 2006 12:28:58 am

I'd say so.

I got around it with some more hacking of my own (which breaks the use of &amp; in XHTML documents but that doesn't really matter much to me as & should work, too).

Visit http://triligon.org

Kirill Subbotin

Friday 31 March 2006 2:20:51 am

hm... probably toString function need to have some parameter like convertSpecialChars as well... Will this solve a problem?

Gabriel Ambuehl

Friday 31 March 2006 3:35:04 am

It might solve the problem (it's mostly what I tacked on it, but it's not entirely clean I think).

Another issue with ezxml is that it silently discards of special chars (like German umlauts, Euro sign etc)

Visit http://triligon.org

Xavier Dutoit

Friday 31 March 2006 4:41:55 am

I'm not sure this bug is related.

http://ez.no/bugs/view/8068

http://www.sydesy.com

Gabriel Ambuehl

Friday 31 March 2006 5:35:06 am

It's likely somehow related.

It's essentially what I saw with my   examples.

Visit http://triligon.org

Valentin Doroschuk

Tuesday 11 April 2006 5:54:29 am

- Added convertSpecialChars parameter into toString().

Xavier Dutoit

Wednesday 12 April 2006 1:47:20 pm

Hi,

It that on pubsvn ? What version ?

X+

http://www.sydesy.com

Kirill Subbotin

Thursday 13 April 2006 12:35:23 am

stable/3.7 rev. 15624, trunk rev. 15625

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 16:01:21
Script start
Timing: Jan 18 2025 16:01:21
Module start 'layout'
Timing: Jan 18 2025 16:01:21
Module start 'content'
Timing: Jan 18 2025 16:01:22
Module end 'content'
Timing: Jan 18 2025 16:01:22
Script end

Main resources:

Total runtime0.7092 sec
Peak memory usage4,096.0000 KB
Database Queries88

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0079 587.9375152.6250
Module start 'layout' 0.00790.0033 740.562539.4453
Module start 'content' 0.01110.6962 780.0078703.2813
Module end 'content' 0.70740.0018 1,483.289124.1563
Script end 0.7091  1,507.4453 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.5133160.0002
Check MTime0.00140.1981160.0001
Mysql Total
Database connection0.00130.186710.0013
Mysqli_queries0.634689.4866880.0072
Looping result0.00080.1148860.0000
Template Total0.674095.020.3370
Template load0.00190.263720.0009
Template processing0.672194.779420.3361
Template load and register function0.00010.014810.0001
states
state_id_array0.00110.160210.0011
state_identifier_array0.00100.138020.0005
Override
Cache load0.00160.2283470.0000
Sytem overhead
Fetch class attribute can translate value0.00050.066040.0001
Fetch class attribute name0.00160.2230140.0001
XML
Image XML parsing0.00170.235640.0004
class_abstraction
Instantiating content class attribute0.00000.0048170.0000
General
dbfile0.00160.2291210.0001
String conversion0.00000.001540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
12content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
15content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 37
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs