Re: [phplib] About db_xsl.inc From: Bryan Willett (bryan <email protected>)
Date: 03/22/01

Making this non-db specific looks good. I'll test it and if it works I'll
update that code.

As to the use of XML DOM, when I originally wrote this I had the code
using the DOM just like you are here. My only concern was additional
overhead cost with little or no functional gain.

Also, for some of my records which have data that XSL doesn't know how to
handle (comma delimited values), I have inserted a function right before
the line that closes the xml result set that formats the data into xml
like so:

alter_dom();
$this->xml = $this->xml . '</result>';

I then override alter_dom() from a class that derives from db_xsl. That
function outputs the un-XSL-friendly data to XML. I know this looks pretty
kludgy but I couldn't think of anything else.

Can you think of a better solution here?

Also, the XML DOM code for inserting somewhat complex xml in alter_dom()
was ugly.

Anyone with more knowledge than I on how PHP handles extensions like XML
DOM care to speculate on the performance diff between these two methods?

Bryan

On Wed, 21 Mar 2001, Jason Belich wrote:

> Hi,
>
> I was just checking out db_xsl.inc. It's very cool, and i think i'll use it
> in my next project. However, wouldn't it be better to change the
> get_result_xml() method to:
>
> function get_result_xml() {
> $this->xml = "";
> $this->xml = $this->xml . '<?xml version="1.0"?>';
> $this->xml = $this->xml . '<result>';
> for ($index = 0; $index < DB_Sql::numrows(); $index++)
> {
> $this->xml = $this->xml . '<row>';
> DB_Sql::next_record();
> while (list($key, $val) = each($this->Record)) {
> $this->xml = $this->xml . '<' . $key . '>' . $this->xml_encode($val)
> . '</' . $key . '>';
> }
> $this->xml = $this->xml . '</row>';
> }
> $this->xml = $this->xml . '</result>';
> return $this->xml;
> }
>
>
> to get rid of the pgsql specificity? OR even better yet, use the DOM
> functions like so:
>
> function get_xml_dom(){
> $this->xmldoc = new_xmldoc("1.0");
> $this->xmlroot = $this->xmldoc->add_root("result");
> for ($i=0;$i<DB_Sql::num_rows();$i++){
> $this->xmlnode[$i] = $this->xmlroot->new_child("row","");
> DB_Sql::next_record();
> while(list($key,$dataitem) = each($this->Record)){
> $this->xmlnode[$i]->new_child($key,$this->xml_encode($dataitem));
> }
> }
> return $this->xmldoc->dumpmem();
> }
>
>
> Note: I haven't tested this yet, but it seems to me to be more correct.
>
> Regards
>
> Jason Belich
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: phplib-unsubscribe <email protected>
> For additional commands, e-mail: phplib-help <email protected>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>