Forums / Developer / Entities are always escaped in ezxml

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

eZ debug

Timing: Jan 18 2025 16:07:18
Script start
Timing: Jan 18 2025 16:07:18
Module start 'content'
Timing: Jan 18 2025 16:07:18
Module end 'content'
Timing: Jan 18 2025 16:07:18
Script end

Main resources:

Total runtime0.2452 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0077 588.8516180.8281
Module start 'content' 0.00770.0072 769.6797105.9141
Module end 'content' 0.01480.2301 875.5938535.7969
Script end 0.2449  1,411.3906 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00391.6018200.0002
Check MTime0.00150.6182200.0001
Mysql Total
Database connection0.00080.329510.0008
Mysqli_queries0.178272.67361410.0013
Looping result0.00210.87291390.0000
Template Total0.229293.510.2292
Template load0.00100.408510.0010
Template processing0.228293.049410.2282
Override
Cache load0.00070.296410.0007
Sytem overhead
Fetch class attribute can translate value0.00120.488910.0012
XML
Image XML parsing0.00040.158210.0004
General
dbfile0.01124.5716200.0006
String conversion0.00000.002030.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs