protected function parseElement(DOMElement $node)
 {
     switch ($node->localName) {
         case "attributeGroup_":
             list($ns, $name, $prefix) = Schema::findParts($node, $node->getAttribute("ref"));
             $g = $this->findAttributeGroup($ns, $name);
             foreach ($g as $att) {
                 $this->attributes[] = $att;
             }
             break;
         case "attribute":
             if ($node->hasAttribute("ref")) {
                 $this->attributes[] = $this->xsd->findAttribute($node, $node->getAttribute("ref"));
             } else {
                 $qualification = $node->hasAttribute("form") ? $node->getAttribute("form") : $this->getSchema()->getAttributeQualification();
                 $required = $node->hasAttribute("use") ? $node->getAttribute("use") != 'optional' : false;
                 if ($node->hasAttribute("type")) {
                     list($ns, $name, $prefix) = Schema::findParts($node, $node->getAttribute("type"));
                     $type = $this->xsd->findType($ns, $name);
                 } else {
                     $type = $this->xsd->createAnonymType($node, $node->getAttribute("name"));
                 }
                 $this->attributes[$node->getAttribute("name")] = new Attribute($this->xsd, $type, $node->getAttribute("name"), $required, $node->getAttribute("default"), $qualification);
             }
             break;
     }
 }
Example #2
0
 protected function parseElement(DOMElement $node)
 {
     switch ($node->localName) {
         case "restriction":
             list($ns, $name, $prefix) = Schema::findParts($node, $node->getAttribute("base"));
             $this->base = $this->xsd->findType($ns, $name);
             //$this->recurse($node);
             break;
     }
 }
Example #3
0
 protected function parseElement(DOMElement $node)
 {
     switch ($node->localName) {
         case "sequence":
         case "choice":
             $this->recurse($node);
             break;
         case "complexContent":
             $this->recurse($node);
             break;
         case "extension":
         case "restriction":
             list($ns, $name, $prefix) = Schema::findParts($node, $node->getAttribute("base"));
             $this->base = $this->xsd->findType($ns, $name);
             $this->recurse($node);
             break;
         case "element":
             if ($node->hasAttribute("ref")) {
                 list($ns, $name, $prefix) = Schema::findParts($node, $node->getAttribute("ref"));
                 $this->elements[] = $this->xsd->findElement($ns, $name);
             } else {
                 $min = $node->hasAttribute("minOccurs") ? $node->getAttribute("minOccurs") : 1;
                 $max = $node->hasAttribute("maxOccurs") ? $node->getAttribute("maxOccurs") : 1;
                 if ($max == "unbounded") {
                     $max = PHP_INT_MAX;
                 }
                 // hack per gestire gli "choice"
                 if ($min > 0) {
                     $testNode = $node;
                     while ($testNode = $testNode->parentNode) {
                         if ($testNode->localName == 'choice') {
                             $min = 0;
                             break;
                         }
                     }
                 }
                 $nillable = $node->getAttribute("nillable") == "true";
                 $qualification = $node->hasAttribute("form") ? $node->getAttribute("form") : $this->getSchema()->getElementQualification();
                 if ($node->hasAttribute("type")) {
                     list($ns, $name, $prefix) = Schema::findParts($node, $node->getAttribute("type"));
                     $type = $this->xsd->findType($ns, $name);
                 } else {
                     $type = $this->xsd->createAnonymType($node, $node->getAttribute("name"));
                 }
                 $this->elements[] = new Element($this->xsd, $type, $node->getAttribute("name"), $min, $max, $nillable);
             }
             break;
         default:
             parent::parseElement($node);
     }
 }