澳门赌场赌大小起步价-护迟学区2019年运动会

首页

AD联系:507867812

澳门赌场赌大小起步价

时间:2019-11-16 04:06:13 作者:澳门永利:系统小说娱乐类排行榜完结版 浏览量:75196

澳门赌场赌大小起步价{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>3{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>3{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>3{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>,见下图

{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>

{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>,见下图

{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>333,如下图

{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>

{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>

如下图

3,如下图

3{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>,见图

澳门赌场赌大小起步价333

{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>

3{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>33{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>

3

{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>

{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>3{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>33{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>3333。

3

澳门赌场赌大小起步价{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>

333{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>。

3

1.3

{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>3{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>3{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>333{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>

2.{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>。

{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>333

3.{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>。

3{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>3{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>3

4.{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>。

33333333{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>3。澳门赌场赌大小起步价

展开全文
相关文章
澳门精品特色盖饭加盟流程

{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>

上汽斯柯达 昊锐 漏油

{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>....

湖南幸运赛车开奖奖金查询

3....

澳门小型导热油炉供应商

3....

大赢家即时比分310

{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>....

相关资讯
亚博体育app官方下载苹果_

{if (is_array($value) && ! $delete){foreach ($value as $suboption => $subvalue){$this->{$option}["$suboption"] = $subvalue;}}else{$this->$option = $value;}}}}}// these are the functions, which are intended to be overriden in user classes/**** @parammixed* @returnobjectDomNode* @accessprivate*/function insertNewResult(&$metadata){if ($this->xmlroot)return $this->xmlroot->new_child($this->tagNameResult, NULL);else{$this->xmlroot = $this->xmldoc->add_root($this->tagNameResult);//PHP 4.0.6 had $root->name as tagname, check for that here...if (!isset($this->xmlroot->{$this->tagname})){$this->tagname = "name";}return $this->xmlroot;}}/***to be written** @paramobject DomNode $parent_row* @parammixed $res* @parammixed $key* @parammixed &metadata* @returnobject DomNode* @access private*/function insertNewRow($parent_row, $res, $key, &$metadata){return$parent_row->new_child($this->tagNameRow, Null);}/***to be written** @paramobject DomNode $parent* @parammixed $res* @parammixed $key* @parammixed &$metadata* @parammixed &$subrow* @returnobject DomNode* @access private*/function insertNewElement($parent, $res, $key, &$metadata, &$subrow){return$parent->new_child($metadata[$key]["name"], $this->xml_encode(trim$res[$key]));}/***to be written** @parammixed $key* @parammixed $value* @parammixed &$metadata* @access private*/function addTableInfo($key, $value, &$metadata) {}// end functions, which are intended to be overriden in user classes// here come some helper functions.../*** make utf8 out of the input data and escape & with & and "< " with "< "* (we assume that when there's no space after < it's a tag, which we need in the xml)*I'm not sure, if this is the standard way, but it works for me.** @paramstring text to be utfed.* @access private*/function xml_encode ($text){if (function_exists("iconv") && isset($this->encoding_from) && isset($this->encoding_to)){ini_set("track_errors",1);$text = iconv($this->encoding_from,$this->encoding_to,ereg_replace("&","&",ereg_replace("< ","< ",$text)));if (! isset($text) ){if (isset($php_errormsg)){$errormsg = "error: $php_errormsg";}else{$errormsg = "undefined iconv error, turn on track_errors in php.ini to get more details";}return PEAR::raiseError($errormsg,Null,PEAR_ERROR_DIE);}else {return $text;}}else{//$text = utf8_encode(ereg_replace("&","&",ereg_replace("< ","< ",$text)));$text = trim(ereg_replace("&","&",ereg_replace("< ","< ",$text)));//echo $text;}return $text;}//taken from kc@hireability.com at http://www.php.net/manual/en/function.array-merge-recursive.php/*** There seemed to be no built in function that would merge two arrays recursively and clobber*any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive*seemed to give unsatisfactory results... it would append duplicate key/values.**So here's a cross between array_merge and array_merge_recursive**//**** @paramarray first array to be merged* @paramarray second array to be merged* @returnarray merged array* @access private*/function array_merge_clobber($a1,$a2){if(!is_array($a1) !is_array($a2)) return false;$newarray = $a1;while (list($key, $val) = each($a2)){if (is_array($val) && is_array($newarray[$key])){$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);}else{$newarray[$key] = $val;}}return $newarray;}/*** Adds a xml string to $this->xmldoc.* It's inserted on the same level as a "normal" resultset, means just as a children of <root>* if a xpath expression is supplied, it takes that for selecting only part of the xml-file** the clean code works only with php 4.0.7* for php4.0.6 :* I found no cleaner method than the below one. it's maybe nasty (xmlObject->string->xmlObject),*but it works. If someone knows how to add whole DomNodes to another one, let me know...** @paramstring xml string* @parammixed xpatheither a string with the xpath expression or an array with "xpath"=>xpath expressionand "root"=tag/subtag/etc, which are the tags to be inserted before the result* @access private*/function doXmlString2Xml ($string,$xpath = Null){//check if we have a recent domxml. otherwise use the workaround...$version = explode(".",phpversion());if (! ($version[0] <= 4 and $version[1] <= 0 and $version[2] < 7) ){if (is_array($xpath)){if (isset($xpath["root"])){$root = $xpath["root"];}$xpath = $xpath["xpath"];}$tmpxml = xmldoc($string);$subroot = $this->xmlroot;if (isset($root)){$roots = explode("/",$root);foreach ($roots as $rootelement){if ( strlen($rootelement) > 0 ){$subroot = $subroot->new_child($rootelement,"");}}}//$this->xmlroot->addchild does some strange things when added nodes from xpath.... so this comment helps out$newchild = $subroot->add_child($this->xmldoc->create_comment("the purpose of this comment is a workaround in sql2php.php line ".__LINE__));// if no xpath is given, just take the whole fileif ( (is_null($xpath))){$newchild->append_child($tmpxml->root());}else{$xctx = $tmpxml->xpath_new_context();$xnode = xpath_eval($xctx,$xpath);foreach ($xnode->nodeset as $node){$newchild->append_child($node);}}}else {$MainXmlString = $this->xmldoc->dumpmem();$string = preg_replace("/<\?xml.*\?>/","",$string);$MainXmlString = preg_replace("/<".$this->xmlroot->{$this->tagname}."\/>/","<".$this->xmlroot->{$this->tagname}."></".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$MainXmlString = preg_replace("/<\/".$this->xmlroot->{$this->tagname}.">/",$string."</".$this->xmlroot->{$this->tagname}.">",$MainXmlString);$this->xmldoc = xmldoc($MainXmlString);$this->xmlroot = $this->xmldoc->root();}}/*** sets the encoding for the db2xml transformation* @paramstring $encoding_from encoding to transform from* @paramstring $encoding_to encoding to transform to* @access public*/function setEncoding ($encoding_from = "ISO-8859-1", $encoding_to ="UTF-8"){$this->encoding_from = $encoding_from;$this->encoding_to = $encoding_to;}/*** @param array $parentTables parent to child relation* @access public*/function SetParentTables($parentTables){foreach ($parentTables as $table => $parent){$table_info["parent_table"][$table]=$parent;}$this->SetOptions(array("user_tableInfo"=>$table_info));}/*** returns the content of the first match of the xpath expression** @paramstring $expr xpath expression* @returnmixed content of the evaluated xpath expression* @accesspublic*/function getXpathValue ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){$firstnode = $xnode->nodeset[0];$children = $firstnode->children();$value = $children[0]->content;return $value;}else{return Null;}}/*** get the values as an array from the childtags from the first match of the xpath expression** @paramstring xpath expression* @returnarray with key->value of subtags* @accesspublic*/function getXpathChildValues ($expr){$xpth = $this->xmldoc->xpath_new_context();$xnode = xpath_eval($xpth,$expr);if (isset ($xnode->nodeset[0])){foreach ($xnode->nodeset[0]->children() as $child){$children = $child->children();$value[$child->{$this->tagname}] = $children[0]->content;}return $value;}else{return Null;}}}?>....

热门资讯