Exemple #1
0
 /**
  * Merge type with another type
  *
  * @todo: Ignore simple types, for now, and especially does not merge 
  * attribute types. Only builds a list with all attributes from all merged 
  * types.
  * 
  * @param slSchemaType $type 
  * @return void
  */
 public function merge(slSchemaType $type)
 {
     // Merge simple type
     $this->empty = $this->empty & $type->empty;
     // Merge attributes
     foreach ($type->attributes as $name => $attribute) {
         $optional = !isset($this->attributes[$name]) || $this->attributes[$name]->optional || $type->attributes[$name]->optional;
         if (!isset($this->attributes[$name])) {
             $this->attributes[$name] = $attribute;
         }
         $this->attributes[$name]->optional = $optional;
     }
     // Make attributes optional, which do not not occur in the merged type
     foreach ($this->attributes as $name => $attribute) {
         if (!isset($type->attributes[$name])) {
             $this->attributes[$name]->optional = true;
         }
     }
     // Merge type automatons
     $this->regularExpression = null;
     $this->automaton->merge($type->automaton);
 }