/** * Returns an <xsd:complexType/> * @param DOMDocument $dom * @return DOMElement */ function getXmlSchema(DOMDocument $dom, $namespaceXMLSchema = 'http://www.w3.org/2001/XMLSchema') { $schema = $dom->createElementNS($namespaceXMLSchema, 'xsd:complexType'); $schema->setAttribute('name', $this->getXmlName(false)); $parent = $this->getClass()->getParentClass(); //if we have a parent class, we will include this infos in the xsd if ($parent != null) { $parent = new self($parent); $complex = $dom->createElementNS($namespaceXMLSchema, 'xsd:complexContent'); $complex->setAttribute('mixed', 'false'); $ext = $dom->createElementNS($namespaceXMLSchema, 'xsd:extension'); $ext->setAttribute('base', $parent->getXmlName(true)); $complex->appendChild($ext); $schema->appendChild($complex); $root = $ext; } else { $root = $schema; } $seq = $dom->createElementNS($namespaceXMLSchema, 'xsd:sequence'); $root->appendChild($seq); $props = $this->getClass()->getProperties(); foreach ($props as $property) { $type = $property->getType(); if ($type != null and !$type->isMap()) { $elm = $dom->createElementNS($namespaceXMLSchema, 'xsd:element'); $elm->setAttribute('minOccurs', '0'); $elm->setAttribute('maxOccurs', '1'); $elm->setAttribute('nillable', 'true'); $elm->setAttribute('name', $property->getName()); $elm->setAttribute('type', $type->getXmlName(true)); $seq->appendChild($elm); } } return $schema; }