Example #1
0
 public function addComplexType(ComplexType $type)
 {
     $phpType = $type->getPhpType();
     $this->types[$phpType] = $type;
     $this->addClassmap($type->getXmlType(), $phpType);
 }
Example #2
0
 protected function addComplexType(ComplexType $type)
 {
     $complexType = $this->document->createElement(static::XSD_NS . ':complexType');
     $complexType->setAttribute('name', $type->getXmlType());
     $all = $this->document->createElement(static::XSD_NS . ':' . ($type instanceof ArrayOfType ? 'sequence' : 'all'));
     $complexType->appendChild($all);
     foreach ($type->all() as $child) {
         $childType = $this->definition->getTypeRepository()->getType($child->getType());
         $element = $this->document->createElement(static::XSD_NS . ':element');
         $element->setAttribute('name', $child->getName());
         if ($childType instanceof ComplexType) {
             $name = $childType->getXmlType();
             if ($childType instanceof ArrayOfType) {
                 $name = $childType->getName();
             }
             $element->setAttribute('type', static::TYPES_NS . ':' . $name);
         } else {
             $element->setAttribute('type', $childType);
         }
         if ($child->isNillable()) {
             $element->setAttribute('nillable', 'true');
         }
         if ($type instanceof ArrayOfType) {
             $element->setAttribute('minOccurs', 0);
             $element->setAttribute('maxOccurs', 'unbounded');
         }
         $all->appendChild($element);
     }
     $this->domSchema->appendChild($complexType);
 }
Example #3
0
 protected function addComplexType(ComplexType $type)
 {
     $complexType = $this->document->createElement(static::XS_NS . ':complexType');
     $complexType->setAttribute('name', $type->getXmlType());
     $all = $this->document->createElement(static::XS_NS . ':' . ($type instanceof ArrayOfType ? 'sequence' : 'sequence'));
     $complexType->appendChild($all);
     foreach ($type->all() as $child) {
         $childType = $this->definition->getTypeRepository()->getType($child->getType());
         $element = $this->document->createElement(static::XS_NS . ':element');
         $element->setAttribute('name', $child->getName());
         $primitiveType = '';
         if (is_string($childType)) {
             $ex = explode(':', $childType);
             $primitiveType = end($ex);
         }
         if ($childType instanceof ComplexType) {
             $name = $childType->getXmlType();
             if ($childType instanceof ArrayOfType) {
                 $name = $childType->getName();
             }
             $element->setAttribute('type', static::TARGET_NS . ':' . $name);
         } elseif (is_string($childType) && in_array($primitiveType, $this->primitiveTypes) && $child->getRestriction()) {
             $element->appendChild($this->addSimpleTypes($primitiveType, $child));
         } else {
             $element->setAttribute('type', static::XS_NS . ':' . $primitiveType);
         }
         $this->setAttributes($child, $element, $type);
         $all->appendChild($element);
     }
     $this->domSchema->appendChild($complexType);
 }