Simple objective which always seems to make me think I'm doing it wrong.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi.

I'm building an XML file.

It is within an OOP structure and is pretty simple.

The method is ...

    /**
     * Turn an error from the W2GlobalData service into normal document as
this will make it easier to integrate downstream.
     *
     * @param \SimpleXMLElement $o_XML
     * @return \SimpleXMLElement
     * @todo Build document to be a correct request header with the
embedded error message.
     */
    public function normaliseError($o_XML)
    {
        $s_XML = <<< END_XML
<?xml version="1.0" encoding="UTF-8"?>
<doc>
    <service>UK Verification (Edited)</service>
    <searchtext>
        <forename>{$this->a_RequestData['forename']}</forename>
        <middlename>{$this->a_RequestData['middlename']}</middlename>
        <surname>{$this->a_RequestData['surname']}</surname>
        <address1>{$this->a_RequestData['address1']}</address1>
        <address2>{$this->a_RequestData['address2']}</address2>
        <postcode>{$this->a_RequestData['postcode']}</postcode>
        <gender>{$this->a_RequestData['gender']}</gender>
        <dob>{$this->a_RequestData['dob']}</dob>

<drivinglicence>{$this->a_RequestData['drivinglicence']}</drivinglicence>
        <passport>{$this->a_RequestData['passport']}</passport>
        <mpan>{$this->a_RequestData['mpan']}</mpan>
    </searchtext>

<clientreference>{$this->a_RequestData['clientreference']}</clientreference>
    <resultcount/>
    <searchdate/>
    <expiry/>
    <timetaken/>
    <reportemailsent/>
    <error>
        {$o_XML->error}
    </error>
</doc>
END_XML;
        return new SimpleXMLElement($s_XML);
    }

Nothing particularly difficult to understand, but I just don't like having
the XML embedded this way.

Ideally, I want a scope aware include function, so I can say _something_
like ...

$s_XML = require_once __CLASS__ . DIRECTORY_SEPARATOR .
'normalisedError.xml';

and have the include be aware of the local scope (so $o_XML and $this are
all happy).

I know I can write a template parser, but I'm just missing an obvious
solution that isn't fat and doesn't require a massive learning for the
other devs.

Ideas?

Thanks for reading.

Richard.


-- 
Richard Quadling
Twitter : @RQuadling
EE : http://e-e.com/M_248814.html
Zend : http://bit.ly/9O8vFY

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux