Ejemplo n.º 1
0
 public function __construct(SimpleXMLElement $xml, $level = 0)
 {
     parent::__construct($xml, $level);
     $attributes = $xml->attributes();
     $base = (string) $attributes['base'];
     if (strpos($base, ':') !== false) {
         // remove the namespace prefix
         $parts = explode(':', $base);
         $base = $parts[1];
     }
     $this->base = $base;
 }
Ejemplo n.º 2
0
 public function __construct(SimpleXMLElement $xml, $level = 0)
 {
     parent::__construct($xml, $level);
     list($prefix, $ns) = each($this->namespaces);
     if ($xml->attributes($ns)) {
         $attributes = $xml->attributes($ns);
     } else {
         // fallback to global namespace if no attributes can be found
         $attributes = $xml->attributes();
     }
     $this->value = (string) $attributes['value'];
 }
Ejemplo n.º 3
0
 public function __construct(SimpleXMLElement $xml, $level = 0)
 {
     parent::__construct($xml, $level);
     $attributes = $xml->attributes();
     $this->name = (string) $attributes['name'];
     $this->type = (string) $attributes['type'];
     if (strpos($this->type, ':') !== false) {
         // remove the namespace prefix
         $parts = explode(':', $this->type);
         $this->type = $parts[1];
     }
     $this->minOccurs = (string) $attributes['minOccurs'];
     $this->maxOccurs = (string) $attributes['maxOccurs'];
 }
Ejemplo n.º 4
0
 public function __construct(SimpleXMLElement $xml, $level = 0)
 {
     parent::__construct($xml, $level);
     $attributes = $xml->attributes();
     $this->name = (string) $attributes['name'];
 }
Ejemplo n.º 5
0
 function visitEnumerationNode(PiBX_ParseTree_Tree $tree)
 {
     $this->plowTypesForLevel($tree->getLevel());
     $this->log($tree->getLevel() . " " . str_pad("  ", $tree->getLevel()) . " enumeration (" . $tree->getValue() . ")");
     if (!$this->currentType() instanceof PiBX_AST_Enumeration) {
         /*
          * On the first enumeration-element a new AST-node for
          * enumerations has to be created.
          * All enumeration-nodes of the Parse-Tree are added as
          * attributes (EnumerationValue-objects) to the
          * AST-node "Enumeration".
          */
         $e = new PiBX_AST_Enumeration();
         $sf = new PiBX_CodeGen_ASTStackFrame($tree->getLevel() - 1, $e);
         array_push($this->stack, $sf);
     }
     if ($this->currentType() instanceof PiBX_AST_Enumeration) {
         $enumType = $tree->getParent()->getBase();
         $enumType = $this->getCorrespondingType($enumType);
         $enum = new PiBX_AST_EnumerationValue($tree->getValue(), $enumType);
         $sf = new PiBX_CodeGen_ASTStackFrame($tree->getLevel(), $enum);
         array_push($this->stack, $sf);
     }
     $this->lastLevel = $tree->getLevel();
 }
Ejemplo n.º 6
0
 /**
  * Recursive top-down parsing (depth-first) of an XSD-Schema.
  * 
  * @param SimpleXMLElement $xml The current xml-node to parse
  * @param PiBX_ParseTree_ParseTree $part Current ParseTree-node
  * @param int $level Parse-tree level (current depth)
  * @return void
  */
 private function parseSchemaNodes(SimpleXMLElement $xml, PiBX_ParseTree_Tree $part, $level = 0)
 {
     $ns = $this->schemaNamespace;
     foreach ($xml->children($ns, true) as $child) {
         $name = (string) $child->getName();
         if ($name == 'element') {
             $newPart = new PiBX_ParseTree_ElementNode($child, $level);
             $attributes = $child->attributes();
             $type = (string) $attributes['type'];
             $type = $this->getStringWithoutNamespace($type);
             $this->typeUsage->addType($type);
         } elseif ($name == 'simpleType') {
             $newPart = new PiBX_ParseTree_SimpleTypeNode($child, $level);
         } elseif ($name == 'complexType') {
             $newPart = new PiBX_ParseTree_ComplexTypeNode($child, $level);
         } elseif ($name == 'sequence') {
             $newPart = new PiBX_ParseTree_SequenceNode($child, $level);
         } elseif ($name == 'choice') {
             $newPart = new PiBX_ParseTree_ChoiceNode($child, $level);
         } elseif ($name == 'restriction') {
             $newPart = new PiBX_ParseTree_RestrictionNode($child, $level);
         } elseif ($name == 'enumeration') {
             $newPart = new PiBX_ParseTree_EnumerationNode($child, $level);
         } elseif ($name == 'attribute') {
             $newPart = new PiBX_ParseTree_AttributeNode($child, $level);
         }
         $this->parseSchemaNodes($child, $newPart, $level + 1);
         $part->add($newPart);
     }
 }
Ejemplo n.º 7
0
 public function __construct(SimpleXMLElement $xml, $level = 0)
 {
     parent::__construct($xml, $level);
     list($ns) = array_keys($xml->getNamespaces());
     $this->elementCount = count($xml->children($ns, true));
 }
Ejemplo n.º 8
0
 public function __construct(SimpleXMLElement $xml, $level = 0)
 {
     parent::__construct($xml, $level);
 }
Ejemplo n.º 9
0
 public function add(PiBX_ParseTree_Tree $tree)
 {
     $this->children[] = $tree;
     $tree->setParent($this);
     return $this;
 }