function create_xml_rec() { //echo microtime()." --Record: create_xml_rec; ".'entering'."<br>"; //else continue on to make the xml string and set it in memcache: // create a new XML document // $doc = new DomDocument('1.0'); $doc = new DOMDocument('1.0', 'UTF-8'); //$doc->appendChild($doc->createProcessingInstruction( // 'xml-stylesheet', 'href="/XSLTemplates/testrec.xsl" type="text/xsl"')); //we want a nice output $doc->formatOutput = true; // create root node $rec = $doc->createElement('record'); $rec = $doc->appendChild($rec); $rec->setAttribute("eid", $this->eid); $rec->setAttribute("type_id", $this->type_id); //add prop/prop group qualifier record data $rpqs = $doc->createElement('rpqs'); $rpqs = $rec->appendChild($rpqs); $rpqs_ar = RecordsSys_EntityManagementSystems::get_rpqs($this->eid); foreach ($rpqs_ar as $rpq_rec) { $rpq = $doc->createElement('repeat_prop_qualifier'); $rpq = $rpqs->appendChild($rpq); foreach ($rpq_rec as $fieldname => $val) { $rpq->setAttribute($fieldname, $val); } } //add prop/prop group qualifiers $prop_quals = $doc->createElement('prop_qualifiers'); $prop_quals = $rec->appendChild($prop_quals); $prop_quals_ar = RecordsSys_EntityManagementSystems::get_prop_qualifiers($this->eid, $this->type_id); foreach ($prop_quals_ar as $prop_qual_value) { $prop_qual = $doc->createElement('prop_qualifier'); $prop_qual = $prop_quals->appendChild($prop_qual); foreach ($prop_qual_value as $fieldname => $val) { $prop_qual->setAttribute($fieldname, $val); } } //print_r ($this->glu->ent_prop_3dhash); //echo microtime()." --Record: create_xml_rec; ".'starting foreach($this->glu->ent_prop_3dhash as $prop_id => $ron)'."<br>"; // process one row at a time foreach ($this->glu->ent_prop_3dhash as $prop_id => $ron) { //skip if not in filter properties set or if filter set is empty if (!empty($this->filter_properties) && !in_array($prop_id, $this->filter_properties)) { //echo "skipping ".$prop_id." for ".$this->eid; continue; } // add node for each row foreach ($ron as $theron => $theprop) { //echo microtime()." ----Record: create_xml_rec; ".'starting loop for $ron: '."$theron, prop_id: $prop_id<br>"; // $roni = 0; //ron index // $theprop = $ron[$roni]; $thepropname = $this->glu->prop_id_prop_obj_hash[$prop_id]->get_property_name(); $thepropgroupid = $this->glu->prop_id_prop_obj_hash[$prop_id]->prop_group_id; $validationspecid = $this->glu->prop_id_prop_obj_hash[$prop_id]->validation_spec_id; $occ = $doc->createElement("property"); $occ = $rec->appendChild($occ); $occ->setAttribute("prop_name", $thepropname); //ffi=(html) form field identifier $occ->setAttribute("ffi", "pi" . $prop_id . "epi" . $theprop->my_ent_prop_id . "ron" . $theron); $occ->setAttribute("prop_group_id", $thepropgroupid); $occ->setAttribute("prop_id", $prop_id); $occ->setAttribute("epi", $theprop->my_ent_prop_id); $occ->setAttribute("ron", $theron); // add a child node for each field $fieldvalue = $theprop->get_val(); $valnode = $doc->createElement("value"); $occ->appendChild($valnode); $value = $doc->createTextNode($fieldvalue); $value = $valnode->appendChild($value); //echo microtime()." ----Record: create_xml_rec; ".'halfway through loop for $ron: '."$ron<br>"; //add validation elements if ($validationspecid) { $validator = $doc->createElement("validator"); $validator = $occ->appendChild($validator); //echo microtime()." ----Record: create_xml_rec; ".' before validationspec = new val...: '."$ron<br>"; $validationspecobj = new validation_spec($validationspecid); // $lookuptablehash = $validationspecobj->lookup_table_hash; //echo "hello66".$validationspecid; $v_regex = $validationspecobj->v_regex; /* if ($lookuptablehash) //print_r($lookuptablehash); { $selectnode = $doc->createElement("select"); $selectnode = $validator->appendChild($selectnode); foreach ($lookuptablehash as $LUTR_id => $cat_name) { $catoptnode = $doc->createElement("option"); $selectnode->appendChild($catoptnode); $catoptnode->setAttribute("LUTR_id",$LUTR_id); $cat_name_txt_node = $doc->createTextNode($cat_name); $cat_name_txt_node = $catoptnode->appendChild($cat_name_txt_node); } } */ if ($v_regex) { $regexnode = $doc->createElement("v_regex"); $regexnode = $validator->appendChild($regexnode); $value = $doc->createTextNode($v_regex); $value = $regexnode->appendChild($value); } } //echo microtime()." ----Record: create_xml_rec; ".'ending loop for $ron: '."$ron<br>"; } } // foreach // get completed xml document //echo microtime()." --Record: create_xml_rec; ".'ended foreach($this->glu->ent_prop_3dhash as $prop_id => $ron)'."<br>"; $xml_string = $doc->saveXML(); // print_r($this->glu->prop_id_prop_obj_hash); //echo microtime()." --Record: create_xml_rec; ".'returning'."<br>"; return $xml_string; /* $xsl = new DOMDocument; $xsl->load($_SERVER['DOCUMENT_ROOT'].'/XSLTemplates/testrec.xsl'); $xsl_string = $xsl->saveXML(); // Configure the transformer $proc = new XSLTProcessor; $proc->importStyleSheet($xsl); // attach the xsl rules $form_string = $proc->transformToXML($doc); return "<table border=1><tr><td>$form_string</td><td><xmp>$form_string</xmp></td></tr></table><xmp>$xml_string</xmp><p>XSL:<br><xmp>$xsl_string</xmp>"; */ }