function purgeIncludes() { $xpath = new domXPath($this); foreach ($xpath->query('/*/xsd:import | /*/xsd:include') as $node) { $node->parentNode->removeChild($node); } }
/** * @see parent::purgeImportedNamespaces */ function purgeImportedNamespaces() { $xpath = new domXPath($this); foreach ($xpath->query('//*[@type]') as $node) { $matches = null; if (preg_match("/insee:(.*)/", $node->getAttribute("type"), $matches)) { $node->setAttribute("type", $matches[1]); } } }
public function XPath($string) { if (is_object($this->domObject) && ctype_print($string)) { $xp = new domXPath($this->domObject); $q = $xp->query($string); $tmpArray = array(); foreach ($q as $node) { $tmpArray[] = $node->textContent; } return $tmpArray; } }
/** * Merge two SimpleXMLElements into a single object * @param SimpleXMLElement $xml1 * @param SimpleXMLElement $xml2 */ public static function SimpleXml_Merge(SimpleXMLElement &$xml1, SimpleXMLElement $xml2) { $dom1 = new DomDocument(); $dom2 = new DomDocument(); $dom1->loadXML($xml1->asXML()); $dom2->loadXML($xml2->asXML()); $xpath = new domXPath($dom2); $xpathQuery = $xpath->query('/*/*'); for ($i = 0; $i < $xpathQuery->length; $i++) { $dom1->documentElement->appendChild($dom1->importNode($xpathQuery->item($i), true)); } $xml1 = simplexml_import_dom($dom1); }
protected function _merge(\SimpleXMLElement $node1, \SimpleXMLElement $node2) { $doc1 = new \DOMDocument(); $doc2 = new \DOMDocument(); $doc1->loadXML($node1->asXML()); $doc2->loadXML($node2->asXML()); $xpath = new \domXPath($doc2); $xpathQuery = $xpath->query('/*/*'); for ($i = 0; $i < $xpathQuery->length; $i++) { $doc1->documentElement->appendChild($doc1->importNode($xpathQuery->item($i), true)); } $node1 = simplexml_import_dom($doc1); return $node1; }
/** * Pumps all child elements of second SimpleXML object into first one. * * @param object $xml1 SimpleXML object * @param object $xml2 SimpleXML object * @return void */ function simplexml_merge(SimpleXMLElement &$xml1, SimpleXMLElement $xml2) { // convert SimpleXML objects into DOM ones $dom1 = new DomDocument(); $dom2 = new DomDocument(); $dom1->loadXML($xml1->asXML()); $dom2->loadXML($xml2->asXML()); // pull all child elements of second XML $xpath = new domXPath($dom2); $xpathQuery = $xpath->query('/*/*'); for ($i = 0; $i < $xpathQuery->length; $i++) { // and pump them into first one $dom1->documentElement->appendChild($dom1->importNode($xpathQuery->item($i), true)); } $xml1 = simplexml_import_dom($dom1); }
//TODO : seems that property mapping breaks the selection ???? //could it be that $selection->AddFeatures($layerObj, $featureReader, 0) is //the one causing a problem when the properies are limited ? if (0 && count($mappings) > 0) { foreach ($mappings as $name => $value) { $queryOptions->AddFeatureProperty($name); //echo "$name $value <br>\n"; } $geomName = $layerObj->GetFeatureGeometryName(); $queryOptions->AddFeatureProperty($geomName); } //get the layer filter value if supplied $layerReader = $resourceService->GetResourceContent($layerObj->GetLayerDefinition()); $xmldoc = new DOMDocument(); $xmldoc->loadXML(ByteReaderToString($layerReader)); $xpathObj = new domXPath($xmldoc); $xpathStr = "/LayerDefinition/VectorLayerDefinition/Filter"; //TODO: need this for DWF or Grid layers? $xpathQuery = $xpathObj->query($xpathStr); $layerFilter = ''; if ($xpathQuery->length > 0) { $layerFilter = $xpathQuery->item(0)->nodeValue; } /* create the combined filter value*/ $combinedFilter = ''; if ($filter != '' && $layerFilter != '') { $combinedFilter = "(" . $filter . ") AND (" . $layerFilter . ")"; } else { $combinedFilter = $filter . $layerFilter; } if ($combinedFilter != '') {
/** * */ public static function mergeXML(\SimpleXMLElement $xml1, \SimpleXMLElement $xml2, $path) { $dom1 = new \DomDocument(); $dom2 = new \DomDocument(); $dom1->loadXML($xml1->asXML()); $dom2->loadXML($xml2->asXML()); $xpath = new \domXPath($dom2); $xpathQuery = $xpath->query($path); for ($i = 0; $i < $xpathQuery->length; $i++) { $dom1->documentElement->appendChild($dom1->importNode($xpathQuery->item($i), true)); } return $xml1 = simplexml_import_dom($dom1); }