Ejemplo n.º 1
0
 /**
  * Add xsd:import tag to XML schema before any childs added
  * 
  * @param string $namespace Namespace URI
  * @param string $code      Shortcut for namespace, fx, ns0. Returned by getNsCode()
  * 
  * @return void
  */
 private function addImportToSchema($namespace, $code)
 {
     if (array_key_exists($namespace, $this->docNamespaces)) {
         if (in_array($namespace, $this->importedNamespaces)) {
             return;
         }
         //$dom = $this->wsdl->toDomDocument();
         //print_r($namespace);
         $this->dom->createAttributeNs($namespace, $code . ":definitions");
         $importEl = $this->dom->createElement($this->xmlSchemaPreffix . ":import");
         $nsAttr = $this->dom->createAttribute("namespace");
         $txtNode = $this->dom->createTextNode($namespace);
         $nsAttr->appendChild($txtNode);
         $nsAttr2 = $this->dom->createAttribute("schemaLocation");
         $schemaLocation = $this->getSchemaLocation($namespace);
         $publicSchema = $this->copyToPublic($schemaLocation, true);
         $publicSchema = $this->copyToPublic($schemaLocation, true);
         $schemaUrl = $this->importsToAbsUrl($publicSchema, $this->getSchemasPath());
         $txtNode2 = $this->dom->createTextNode($schemaUrl);
         $nsAttr2->appendChild($txtNode2);
         $importEl->appendChild($nsAttr);
         $importEl->appendChild($nsAttr2);
         //$this->wsdl->getSchema();
         //$xpath = new \DOMXPath($this->dom);
         //$query = "//*[local-name()='types']/child::*/*";
         //$firstElement = $xpath->query($query);
         //if (!is_object($firstElement->item(0))) {
         //    $query = "//*[local-name()='types']/child::*";
         //    $schema = $xpath->query($query);
         //    $schema->item(0)->appendChild($importEl);
         //} else {
         //    $this->wsdl->getSchema()->insertBefore($importEl, $firstElement->item(0));
         //}
         //$this->xmlSchemaImports
         //$this->wsXmlSchema->appendChild();
         array_push($this->xmlSchemaImports, $importEl);
         array_push($this->importedNamespaces, $namespace);
     }
 }