Problems inserting into $dataMap

Author Message

Bjarte Lunde

Monday 26 February 2007 6:19:00 am

I'm having difficulties inserting this to the "desc" attribute (XML-block)
Do you see anything i'm doing wrong?

Code:

    // Change characters
    $fraChar = array("æ", "ø", "å", """, "
", "\n", "\r");
    $tilChar = array("&aelig;", "&oslash;", "&aring;", "&quote;", " ", "<br>", "<br> ");
    $description = '<p>'.str_replace( $fraChar, $tilChar, $attributes->elementTextContentByName( 'DESCRIPTION' ) ).'</p>';
    $description = trim( $description );
    $dataMap['desc']->setAttribute( 'data_text', $description );
    $dataMap['desc']->store();

Original XML-text:

<DESCRIPTION>Bilen er topp utstyrt!&#xd;
F1 giring p&#229; rattet&#xd;
18&quot;sommer&#xd;
17&quot;vinter&#xd;
sportsunderstell&#xd;
sportsseter&#xd;
++++</DESCRIPTION>

Betsy Gamrat

Monday 26 February 2007 10:17:58 am

I have had good luck with this approach, basically taking a text string and wrapping it with XML data.

I think if you ran the conversion code, then wrapped it with the XML tags, you would be okay.

$description = XML_wrap($Data);

function XML_wrap($text)
{
return '<?xml version="1.0" encoding="UTF-8"?>' ."\n".
                '<section xmlns:image="http://ez.no/namespaces/ezpublish3/image/"'."\n".
                '    xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/"'."\n".
                '    xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/"><paragraph>'.
                $text."</paragraph>\n</section>\n";
}

Bjarte Lunde

Monday 26 February 2007 2:24:57 pm

I tried your suggestion, but it didn't do the trick.

I also have this code which inserts with no problem into a xml-block

    $equipment = '<ul>';
    $eqChild = $attributes->elementChildrenByName( 'EQUIPMENT' );
    foreach( $eqChild as $eqElement )
    {
        $equipment = $equipment.'<li>'.trim( $eqElement->textContent() ).'</li>';
    }
    $equipment = $equipment.'</ul>';
    $dataMap['equipment']->setAttribute( 'data_text', $equipment );
    $dataMap['equipment']->store();

Betsy Gamrat

Tuesday 27 February 2007 7:22:59 pm

It may be the <b><br></b> tags. You might want to try using a different substitution just to test the idea. For example, use <b>!</b>, just as a marker.

I don't think all versions of eZ support <b><br></b>.

Good luck.

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