コード例 #1
0
 /**
  * Write a property
  *
  * @param ODataProperty &$odataProperty Property to be written
  * @param boolean       $isTopLevel     is link top level or not.
  * 
  * @return nothing
  */
 protected function beginWriteProperty(ODataProperty &$odataProperty, $isTopLevel)
 {
     $this->xmlWriter->startElementNS(ODataConstants::ODATA_NAMESPACE_PREFIX, $odataProperty->name, null);
     if ($odataProperty->typeName != null) {
         $this->xmlWriter->startAttributeNs(ODataConstants::ODATA_METADATA_NAMESPACE_PREFIX, ODataConstants::ATOM_TYPE_ATTRIBUTE_NAME, null);
         $this->xmlWriter->text($odataProperty->typeName);
     }
     if ($isTopLevel) {
         $this->xmlWriter->startAttribute(ODataConstants::XMLNS_NAMESPACE_PREFIX);
         $this->xmlWriter->text(ODataConstants::ODATA_METADATA_NAMESPACE);
         $this->xmlWriter->startAttributeNs(ODataConstants::XMLNS_NAMESPACE_PREFIX, ODataConstants::ODATA_NAMESPACE_PREFIX, null);
         $this->xmlWriter->text(ODataConstants::ODATA_NAMESPACE);
         $this->xmlWriter->startAttributeNs(ODataConstants::XMLNS_NAMESPACE_PREFIX, ODataConstants::ODATA_METADATA_NAMESPACE_PREFIX, null);
         $this->xmlWriter->text(ODataConstants::ODATA_METADATA_NAMESPACE);
     }
     if ($odataProperty->typeName != null || $isTopLevel) {
         $this->xmlWriter->endAttribute();
     }
 }
コード例 #2
0
ファイル: XML.php プロジェクト: trickyplan/codeine
setFn('Render', function ($Call) {
    $XML = new XMLWriter();
    $XML->openMemory();
    $XML->startDocument('1.0', 'UTF-8');
    $XML->setIndent(true);
    if (isset($Call['Output']['Root'])) {
        $XML->startElement($Call['Output']['Root']);
        if (isset($Call['Namespace'])) {
            $XML->startAttribute('xmlns');
            $XML->text($Call['Namespace']);
            $XML->endAttribute();
        }
        if (isset($Call['Attributes'])) {
            foreach ($Call['Attributes'] as $Key => $Value) {
                if (is_array($Value)) {
                    $XML->startAttributeNs($Value['Prefix'], $Value['Key'], null);
                    $XML->text($Value['Value']);
                } else {
                    $XML->startAttribute($Key);
                    $XML->text($Value);
                }
                $XML->endAttribute();
            }
        }
        $Root = '';
        F::Map($Call['Output']['Content'], function ($Key, $Value) use($XML, &$Root) {
            if (substr($Key, 0, 1) == '@') {
                $XML->startAttribute(substr($Key, 1));
                $XML->text($Value);
                $XML->endAttribute();
            } else {