Development

Changeset 12822

You must first sign up to be able to contribute.

Changeset 12822

Show
Ignore:
Timestamp:
11/09/08 13:04:25 (5 years ago)
Author:
chrisk
Message:

[ckWebServicePlugin][ckWsdlGenerator] changed array type implementation to be ws-i compliant;

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/ckWebServicePlugin/branches/ckWsdlGenerator/xsd/ckXsdArrayType.class.php

    r12818 r12822  
    1717 * @author     Christian Kerl <christian-kerl@web.de> 
    1818 */ 
    19 class ckXsdArrayType extends ckXsdType 
     19class ckXsdArrayType extends ckXsdComplexType 
    2020{ 
    21   /** 
    22    * The name of the root node of the xml representation. 
    23    */ 
    24   const ELEMENT_NAME = 'complexType'; 
    25  
    2621  /** 
    2722   * The suffix of a type name, which identifies it as array type. 
     
    3227   * The prefix every array type name starts with. 
    3328   */ 
    34   const NAME_PREFIX = 'ArrayOf'; 
     29  const NAME_SUFFIX = 'Array'; 
    3530 
    3631  /** 
     
    5045      if(!is_null($elementType)) 
    5146      { 
    52         return new ckXsdArrayType(self::NAME_PREFIX.ckString::ucfirst($elementTypeName), ckXsdNamespace::get('tns'), $elementType); 
     47        return new ckXsdArrayType(ckString::ucfirst($elementTypeName).self::NAME_SUFFIX, ckXsdNamespace::get('tns'), $elementType); 
    5348      } 
    5449    } 
     
    9792 
    9893  /** 
    99    * @see ckDOMSerializable::getNodeName() 
     94   * @see ckXsdComplexType::getElements() 
    10095   */ 
    101   public function getNodeName() 
     96  public function getElements() 
    10297  { 
    103     return self::ELEMENT_NAME; 
     98    return array(new ckXsdComplexTypeElement('item', $this->getElementType(), '0', 'unbound')); 
     99  } 
     100 
     101  /** 
     102   * Hides ckXsdComplexType::addElement(), does nothing. 
     103   * 
     104   * @see ckXsdComplexType::addElement() 
     105   */ 
     106  public function addElement(ckXsdComplexTypeElement $element) 
     107  { 
    104108  } 
    105109 
     
    117121    $this->setElementType($elementType); 
    118122  } 
    119  
    120   /** 
    121    * @see ckDOMSerializable::serialize() 
    122    */ 
    123   public function serialize(DOMDocument $document) 
    124   { 
    125     $xsd = ckXsdNamespace::get('xsd'); 
    126  
    127     $node = $document->createElementNS($xsd->getUrl(), $xsd->qualify($this->getNodeName())); 
    128     $node->setAttribute('name', $this->getName()); 
    129  
    130     $attr = $document->createElementNS($xsd->getUrl(), $xsd->qualify('attribute')); 
    131     $attr->setAttribute('ref', 'soapenc:arrayType'); 
    132     $attr->setAttribute('wsdl:arrayType', $this->getElementType()->getQualifiedName().self::ARRAY_SUFFIX); 
    133  
    134     $restriction = $document->createElementNS($xsd->getUrl(), $xsd->qualify('restriction')); 
    135     $restriction->setAttribute('base', 'soapenc:Array'); 
    136     $restriction->appendChild($attr); 
    137  
    138     $complexContent = $document->createElementNS($xsd->getUrl(), $xsd->qualify('complexContent')); 
    139     $complexContent->appendChild($restriction); 
    140  
    141     $node->appendChild($complexContent); 
    142  
    143     return $node; 
    144   } 
    145123} 
  • plugins/ckWebServicePlugin/branches/ckWsdlGenerator/xsd/ckXsdComplexTypeElement.class.php

    r12155 r12822  
    3737   */ 
    3838  protected $type; 
     39 
     40  /** 
     41   * The minimum occurs of the element. 
     42   * 
     43   * @var string 
     44   */ 
     45  protected $minOccurs; 
     46 
     47  /** 
     48   * The maximum occurs of the element. 
     49   * 
     50   * @var string 
     51   */ 
     52  protected $maxOccurs; 
    3953 
    4054  /** 
     
    7993 
    8094  /** 
     95   * Gets the minimum occurs of the element. 
     96   * 
     97   * @return string The minimum occurs of the element 
     98   */ 
     99  public function getMinOccurs() 
     100  { 
     101    return $this->minOccurs; 
     102  } 
     103 
     104  /** 
     105   * Sets the minimum occurs of the element. 
     106   * 
     107   * @param string $value The minimum occurs of the element 
     108   */ 
     109  public function setMinOccurs($value) 
     110  { 
     111    $this->minOccurs = $value; 
     112  } 
     113 
     114  /** 
     115   * Gets the maximum occurs of the element. 
     116   * 
     117   * @return string The maximum occurs of the element 
     118   */ 
     119  public function getMaxOccurs() 
     120  { 
     121    return $this->maxOccurs; 
     122  } 
     123 
     124  /** 
     125   * Sets the maximum occurs of the element. 
     126   * 
     127   * @param string $value The maximum occurs of the element 
     128   */ 
     129  public function setMaxOccurs($value) 
     130  { 
     131    $this->maxOccurs = $value; 
     132  } 
     133 
     134  /** 
    81135   * @see ckDOMSerializable::getNodeName() 
    82136   */ 
     
    89143   * Constructor initializing the element with a given name and a given type. 
    90144   * 
    91    * @param string    $name The name of the element 
    92    * @param ckXsdType $type The type of the element 
     145   * @param string    $name      The name of the element 
     146   * @param ckXsdType $type      The type of the element 
     147   * @param string    $minOccurs The minimum occurs of the element 
     148   * @param string    $maxOccurs The maximum occurs of the element 
    93149   */ 
    94   public function __construct($name, ckXsdType $type
     150  public function __construct($name, ckXsdType $type, $minOccurs = null, $maxOccur = null
    95151  { 
    96152    $this->setName($name); 
    97153    $this->setType($type); 
     154    $this->setMinOccurs($minOccurs); 
     155    $this->setMaxOccurs($maxOccur); 
    98156  } 
    99157 
     
    109167    $node->setAttribute('type', $this->getType()->getQualifiedName()); 
    110168 
     169    if(!is_null($this->getMinOccurs())) 
     170    { 
     171      $node->setAttribute('minOccurs', $this->getMinOccurs()); 
     172    } 
     173 
     174    if(!is_null($this->getMaxOccurs())) 
     175    { 
     176      $node->setAttribute('maxOccurs', $this->getMaxOccurs()); 
     177    } 
     178 
    111179    return $node; 
    112180  }