Example #1
0
 /**
  * Converts the 'font-size' CSS style.
  *
  * This method receives a $targetProperty DOMElement and converts the given 
  * style with $styleName and $styleValue to attributes on this 
  * $targetProperty.
  * 
  * @param DOMElement $targetProperty 
  * @param string $styleName 
  * @param ezcDocumentPcssStyleValue $styleValue 
  */
 public function convert(DOMElement $targetProperty, $styleName, ezcDocumentPcssStyleValue $styleValue)
 {
     $mmValue = sprintf('%smm', $styleValue->value);
     $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_FO, "fo:{$styleName}", $mmValue);
     $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, "style:{$styleName}-asian", $mmValue);
     $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, "style:{$styleName}-complex", $mmValue);
 }
Example #2
0
 /**
  * Create basics tags. Definitions (root), schema (contain types), port type
  * and binding.
  *
  * @return void
  */
 protected function createMajorElements()
 {
     // >> definitions
     $this->oDefinitions = $this->createElementNS(self::NS_WSDL, 'wsdl:definitions');
     $this->oDefinitions->setAttributeNS(self::NS_XML, 'xmlns:soap-enc', self::NS_SOAP_ENC);
     $this->oDefinitions->setAttributeNS(self::NS_XML, 'xmlns:soap-env', self::NS_SOAP_ENV);
     $this->oDefinitions->setAttributeNS(self::NS_XML, 'xmlns:tns', $this->sTns);
     $this->oDefinitions->setAttributeNS(self::NS_XML, 'xmlns:wsdl', self::NS_WSDL);
     $this->oDefinitions->setAttributeNS(self::NS_XML, 'xmlns:xsd', self::NS_XSD);
     $this->oDefinitions->setAttribute('targetNamespace', $this->sTns);
     $this->appendChild($this->oDefinitions);
     // >> definitions >> types
     $oTypes = $this->createElementNS(self::NS_WSDL, 'types');
     $this->oDefinitions->appendChild($oTypes);
     // >> definitions >> types >> schema
     $this->oSchema = $this->createElementNS(self::NS_XSD, 'schema');
     $this->oSchema->setAttribute('targetNamespace', $this->sTns);
     $oTypes->appendChild($this->oSchema);
     // >> definitions >> types >>port type
     $this->oPortType = $this->createElementNS(self::NS_WSDL, 'portType');
     $this->oPortType->setAttribute('name', $this->oClass->name . 'PortType');
     // >> definitions >> types >> binding
     $this->oBinding = $this->createElementNS(self::NS_WSDL, 'binding');
     $this->oBinding->setAttribute('name', $this->oClass->name . 'Binding');
     $this->oBinding->setAttribute('type', 'tns:' . $this->oClass->name . 'PortType');
     // >> definitions >> types >> binding >> soap binding
     $oBindingSoap = $this->createElementNS(self::NS_SOAP_ENV, 'binding');
     $oBindingSoap->setAttribute('style', 'rpc');
     $oBindingSoap->setAttribute('transport', self::BINDING);
     $this->oBinding->appendChild($oBindingSoap);
 }
Example #3
0
 /**
  * Creates the styles with $styleAttributes for the given $odtElement.
  * 
  * @param ezcDocumentOdtStyleInformation $styleInfo 
  * @param DOMElement $odtElement 
  * @param array $styleAttributes 
  * @return void
  */
 public function createStyle(ezcDocumentOdtStyleInformation $styleInfo, DOMElement $odtElement, array $styleAttributes)
 {
     $styleName = $this->getUniqueStyleName($odtElement->localName);
     $style = $styleInfo->automaticStyleSection->appendChild($styleInfo->automaticStyleSection->ownerDocument->createElementNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:style'));
     $style->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:family', 'table');
     $style->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:name', $styleName);
     $odtElement->setAttributeNS(ezcDocumentOdt::NS_ODT_TABLE, 'table:style-name', $styleName);
     $this->tablePropertyGenerator->createProperty($style, $styleAttributes);
 }
Example #4
0
 /**
  * Required by the ArrayAccess interface.
  *
  * @param  string $offset
  * @param  string $value
  * @return string
  */
 public function offsetSet($offset, $value)
 {
     $this->ensureAppended();
     if (strpos($offset, ':') !== false) {
         list($ns, $attr) = explode(':', $offset, 2);
         return $this->_element->setAttributeNS(Zend_Feed::lookupNamespace($ns), $attr, $value);
     } else {
         return $this->_element->setAttribute($offset, $value);
     }
 }
 /**
  * Returns the DOMElement representation of the worksheet 
  *
  * @return \DOMElement
  */
 public function getWorksheet()
 {
     if (is_null($this->worksheet)) {
         $document = $this->getDocument();
         $this->worksheet = $this->append('worksheet', array(), $document);
         $this->worksheet->setAttributeNS(static::$namespaces['xmlns'], 'xmlns:r', static::$namespaces['relationships']);
     }
     $this->updateDocument();
     return $this->worksheet;
 }
Example #6
0
 /**
  * Required by the ArrayAccess interface.
  *
  * @param  string $offset
  * @param  string $value
  * @return string
  */
 public function offsetSet($offset, $value)
 {
     $this->ensureAppended();
     if (strpos($offset, ':') !== false) {
         list($ns, $attr) = explode(':', $offset, 2);
         // DOMElement::setAttributeNS() requires $qualifiedName to have a prefix
         return $this->_element->setAttributeNS(Zend_Feed::lookupNamespace($ns), $offset, $value);
     } else {
         return $this->_element->setAttribute($offset, $value);
     }
 }
Example #7
0
 /**
  * Create an AttributeValue.
  *
  * @param mixed $value The value of this element. Can be one of:
  *  - string                      Create an attribute value with a simple string.
  *  - DOMElement(AttributeValue)  Create an attribute value of the given DOMElement.
  *  - DOMElement                  Create an attribute value with the given DOMElement as a child.
  */
 public function __construct($value)
 {
     assert('is_string($value) || $value instanceof DOMElement');
     if (is_string($value)) {
         $doc = new DOMDocument();
         $this->element = $doc->createElementNS(SAML2_Const::NS_SAML, 'saml:AttributeValue');
         $this->element->setAttributeNS(SAML2_Const::NS_XSI, 'xsi:type', 'xs:string');
         $this->element->appendChild($doc->createTextNode($value));
         /* Make sure that the xs-namespace is available in the AttributeValue (for xs:string). */
         $this->element->setAttributeNS(SAML2_Const::NS_XS, 'xs:tmp', 'tmp');
         $this->element->removeAttributeNS(SAML2_Const::NS_XS, 'tmp');
         return;
     }
     if ($value->namespaceURI === SAML2_Const::NS_SAML && $value->localName === 'AttributeValue') {
         $this->element = SAML2_Utils::copyElement($value);
         return;
     }
     $doc = new DOMDocument();
     $this->element = $doc->createElementNS(SAML2_Const::NS_SAML, 'saml:AttributeValue');
     SAML2_Utils::copyElement($value, $this->element);
 }
Example #8
0
 /**
  * Creates the styles with $styleAttributes for the given $odtElement.
  * 
  * @param ezcDocumentOdtStyleInformation $styleInfo 
  * @param DOMElement $odtElement 
  * @param array $styleAttributes 
  */
 public function createStyle(ezcDocumentOdtStyleInformation $styleInfo, DOMElement $odtElement, array $styleAttributes)
 {
     $styleName = $this->getUniqueStyleName($odtElement->localName);
     $style = $styleInfo->automaticStyleSection->appendChild($styleInfo->automaticStyleSection->ownerDocument->createElementNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:style'));
     $style->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:family', 'paragraph');
     $style->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:name', $styleName);
     $odtElement->setAttributeNS(ezcDocumentOdt::NS_ODT_TEXT, 'text:style-name', $styleName);
     // Setting the margins in a list contained paragraph results in
     // overwriting the list margin. Therefore we skip paragraph property
     // generation completely here.
     // @TODO: Does this have any strange effects? Find a nicer solution?
     if ($odtElement->parentNode->localName !== 'list-item') {
         $this->paragraphPropertyGenerator->createProperty($style, $styleAttributes);
     }
     $this->textPropertyGenerator->createProperty($style, $styleAttributes);
 }
 /**
  * Converts the 'text-decoration' CSS style.
  *
  * This method receives a $targetProperty DOMElement and converts the given 
  * style with $styleName and $styleValue to attributes on this 
  * $targetProperty.
  * 
  * @param DOMElement $targetProperty 
  * @param string $styleName 
  * @param ezcDocumentPcssStyleValue $styleValue 
  */
 public function convert(DOMElement $targetProperty, $styleName, ezcDocumentPcssStyleValue $styleValue)
 {
     foreach ($styleValue->value as $listElement) {
         switch ($listElement) {
             case 'line-through':
                 $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:text-line-through-type', 'single');
                 $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:text-line-through-style', 'solid');
                 $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:text-line-through-width', 'auto');
                 $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:text-line-through-color', 'font-color');
                 break;
             case 'underline':
                 $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:text-underline-type', 'single');
                 $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:text-underline-style', 'solid');
                 $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:text-underline-width', 'auto');
                 $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:text-underline-color', 'font-color');
                 break;
             case 'overline':
                 break;
             case 'blink':
                 $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:text-blinking', 'true');
                 break;
         }
     }
 }
Example #10
0
 /**
  * Required by the ArrayAccess interface.
  *
  * @internal
  */
 public function offsetSet($offset, $value)
 {
     if (!is_scalar($value)) {
         throw new InvalidArgumentException('Element values must be scalars, ' . gettype($value) . ' given');
     }
     $this->_ensureAppended();
     if (strpos($offset, ':') !== false) {
         list($ns) = explode(':', $offset, 2);
         $result = $this->_element->setAttributeNS(Horde_Xml_Element::lookupNamespace($ns), $offset, $value);
     } else {
         $result = $this->_element->setAttribute($offset, $value);
     }
     if ($result) {
         $this->_expireCachedChildren();
         return true;
     } else {
         return false;
     }
 }
Example #11
0
 /**
  * Recursive method to create childs from array
  *
  * @param \DOMDocument $dom Handler to DOMDocument
  * @param \DOMElement $node Handler to DOMElement (child)
  * @param array &$data Array of data to append to the $node.
  * @param string $format Either 'attribute' or 'tags'. This determines where nested keys go.
  * @return void
  * @throws \Cake\Utility\Exception\XmlException
  */
 protected static function _fromArray($dom, $node, &$data, $format)
 {
     if (empty($data) || !is_array($data)) {
         return;
     }
     foreach ($data as $key => $value) {
         if (is_string($key)) {
             if (method_exists($value, 'toArray')) {
                 $value = $value->toArray();
             }
             if (!is_array($value)) {
                 if (is_bool($value)) {
                     $value = (int) $value;
                 } elseif ($value === null) {
                     $value = '';
                 }
                 $isNamespace = strpos($key, 'xmlns:');
                 if ($isNamespace !== false) {
                     $node->setAttributeNS('http://www.w3.org/2000/xmlns/', $key, $value);
                     continue;
                 }
                 if ($key[0] !== '@' && $format === 'tags') {
                     $child = null;
                     if (!is_numeric($value)) {
                         // Escape special characters
                         // http://www.w3.org/TR/REC-xml/#syntax
                         // https://bugs.php.net/bug.php?id=36795
                         $child = $dom->createElement($key, '');
                         $child->appendChild(new \DOMText($value));
                     } else {
                         $child = $dom->createElement($key, $value);
                     }
                     $node->appendChild($child);
                 } else {
                     if ($key[0] === '@') {
                         $key = substr($key, 1);
                     }
                     $attribute = $dom->createAttribute($key);
                     $attribute->appendChild($dom->createTextNode($value));
                     $node->appendChild($attribute);
                 }
             } else {
                 if ($key[0] === '@') {
                     throw new XmlException('Invalid array');
                 }
                 if (is_numeric(implode('', array_keys($value)))) {
                     // List
                     foreach ($value as $item) {
                         $itemData = compact('dom', 'node', 'key', 'format');
                         $itemData['value'] = $item;
                         static::_createChild($itemData);
                     }
                 } else {
                     // Struct
                     static::_createChild(compact('dom', 'node', 'key', 'value', 'format'));
                 }
             }
         } else {
             throw new XmlException('Invalid array');
         }
     }
 }
Example #12
0
 /**
  * Add an attribute to the target element node.
  *
  * @param \DOMElement $target
  * @param \DOMAttr $source
  */
 private function addAttribute(\DOMElement $target, \DOMAttr $source)
 {
     list($prefix, $name, $uri) = $this->getNodeDefinition($source);
     if (empty($prefix)) {
         $target->setAttribute($name, $source->value);
     } else {
         $target->setAttributeNS($uri, $prefix . ':' . $name, $source->value);
     }
 }
Example #13
0
 public function root(\DOMElement &$root)
 {
     $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:codesearch', 'http://www.google.com/codesearch/schemas/sitemap/1.0');
 }
Example #14
0
 /**
  * processAttributesBySchema
  * Parses customattributes attribute and splits it into actual
  * custom: xml attributes, passes processing of normal attributes
  * to parent class.
  *
  * @param DOMElement $element
  */
 function processAttributesBySchema($element)
 {
     // custom attributes conversion
     $attr = $element->getAttribute('customattributes');
     if ($attr) {
         $attrArray = explode('attribute_separation', $attr);
         foreach ($attrArray as $attr) {
             if ($attr !== '' && strpos($attr, '|') !== false) {
                 list($attrName, $attrValue) = explode('|', $attr);
                 $element->setAttributeNS('http://ez.no/namespaces/ezpublish3/custom/', 'custom:' . $attrName, $attrValue);
             }
         }
     }
     parent::processAttributesBySchema($element);
 }
Example #15
0
 /**
  * Set attributes which are not (yet?) extracted from PCSS.
  * 
  * @param DOMElement $prop 
  */
 protected function setFixedAttributes(DOMElement $prop)
 {
     // Align table to margins specified
     $prop->setAttributeNS(ezcDocumentOdt::NS_ODT_TABLE, 'table:align', 'margins');
     $prop->setAttributeNS(ezcDocumentOdt::NS_ODT_TABLE, 'table:border-model', 'separating');
 }
Example #16
0
 /**
  * Recursive method to create childs from array
  *
  * @param DOMDocument $dom Handler to DOMDocument
  * @param DOMElement $node Handler to DOMElement (child)
  * @param array $data Array of data to append to the $node.
  * @param string $format Either 'attribute' or 'tags'.  This determines where nested keys go.
  * @return void
  * @throws XmlException
  */
 protected static function _fromArray($dom, $node, &$data, $format)
 {
     if (empty($data) || !is_array($data)) {
         return;
     }
     foreach ($data as $key => $value) {
         if (is_string($key)) {
             if (!is_array($value)) {
                 if (is_bool($value)) {
                     $value = (int) $value;
                 } elseif ($value === null) {
                     $value = '';
                 }
                 $isNamespace = strpos($key, 'xmlns:');
                 if ($isNamespace !== false) {
                     $node->setAttributeNS('http://www.w3.org/2000/xmlns/', $key, $value);
                     continue;
                 }
                 if ($key[0] !== '@' && $format === 'tags') {
                     $child = $dom->createElement($key, $value);
                     $node->appendChild($child);
                 } else {
                     if ($key[0] === '@') {
                         $key = substr($key, 1);
                     }
                     $attribute = $dom->createAttribute($key);
                     $attribute->appendChild($dom->createTextNode($value));
                     $node->appendChild($attribute);
                 }
             } else {
                 if ($key[0] === '@') {
                     throw new XmlException(__d('cake_dev', 'Invalid array'));
                 }
                 if (array_keys($value) === range(0, count($value) - 1)) {
                     // List
                     foreach ($value as $item) {
                         $data = compact('dom', 'node', 'key', 'format');
                         $data['value'] = $item;
                         self::_createChild($data);
                     }
                 } else {
                     // Struct
                     self::_createChild(compact('dom', 'node', 'key', 'value', 'format'));
                 }
             }
         } else {
             throw new XmlException(__d('cake_dev', 'Invalid array'));
         }
     }
 }
Example #17
0
 /**
  * @param \DOMElement $node
  * @param array $value
  * @param $options
  */
 protected static function appendAttributes(\DOMElement $node, $value, $options)
 {
     if (!empty($value[$options[self::OPTION_ATTR_INDEX]])) {
         foreach ($value[$options[self::OPTION_ATTR_INDEX]] as $name => $value) {
             if (strpos($name, 'xmlns:') === 0) {
                 $node->setAttributeNS('http://www.w3.org/2000/xmlns/', $name, $value);
             } else {
                 $node->setAttribute($name, $value);
             }
         }
     }
 }
Example #18
0
File: list.php Project: bmdevel/ezc
 /**
  * Creates a new <text:list-style/> and applies it to the given 
  * $odtElement.
  *
  * This method creates and returns a new list style DOMElement in 
  * $styleInfo for $odtElement and assigns its name to the $odtElement. The 
  * list style can then be filled with list properties of different levels.
  * 
  * @param DOMElement $odtElement 
  * @param ezcDocumentOdtStyleInformation $styleInfo 
  * @return DOMElement
  */
 protected function createNewListStyle(DOMElement $odtElement, ezcDocumentOdtStyleInformation $styleInfo)
 {
     $listStyle = $styleInfo->automaticStyleSection->appendChild($styleInfo->automaticStyleSection->ownerDocument->createElementNS(ezcDocumentOdt::NS_ODT_TEXT, 'text:list-style'));
     $listStyle->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:name', $styleName = $this->getUniqueStyleName('l'));
     $odtElement->setAttributeNS(ezcDocumentOdt::NS_ODT_TEXT, 'text:style-name', $styleName);
     // OOO attaches IDs to root lists, so do we.
     $odtElement->setAttributeNS(ezcDocumentOdt::NS_XML, 'xml:id', sprintf("%s%s", 'list', ++$this->id));
     return $listStyle;
 }
Example #19
0
 /**
  * Converts CSS 'border' style.
  *
  * This method receives a $targetProperty DOMElement and converts the given 
  * style with $styleName and $styleValue to attributes on this 
  * $targetProperty.
  * 
  * @param DOMElement $targetProperty 
  * @param string $styleName 
  * @param ezcDocumentPcssStyleValue $styleValue 
  */
 public function convert(DOMElement $targetProperty, $styleName, ezcDocumentPcssStyleValue $styleValue)
 {
     foreach ($styleValue->value as $type => $borderValues) {
         $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_FO, "fo:border-{$type}", sprintf("%smm %s %s", $borderValues['width'], $borderValues['style'], ezcDocumentOdtPcssConverterTools::serializeColor($borderValues['color'])));
     }
 }
Example #20
0
 /**
  * Internal helper to set the needed attributes on the xsl:stylesheet node
  *
  * @param \DOMElement $node
  */
 private function setStylesheetProperties(\DOMElement $node)
 {
     $node->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:func', 'http://exslt.org/functions');
     $node->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:php', 'http://php.net/xsl');
     $node->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:' . $this->prefix, $this->xmlns);
     $eep = explode(' ', $node->getAttribute('extension-element-prefixes'));
     $eep = array_unique(array_merge($eep, array('php', 'func')));
     $node->setAttribute('extension-element-prefixes', trim(join(' ', $eep)));
     $erp = explode(' ', $node->getAttribute('exclude-result-prefixes'));
     $erp = array_unique(array_merge($erp, array('php', 'func', $this->prefix)));
     $node->setAttribute('exclude-result-prefixes', trim(join(' ', $erp)));
 }
Example #21
0
 /**
  * Sets fixed properties.
  *
  * Some properties need to be set, but cannot be influenced by PCSS. These 
  * are set in this method.
  * 
  * @param DOMElement $prop 
  */
 protected function setFixedAttributes(DOMElement $prop)
 {
     // Align table cells via fo:align
     $prop->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:text-align-source', 'fix');
 }
Example #22
0
 public function root(\DOMElement &$root)
 {
     $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:mobile', 'http://www.google.com/schemas/sitemap-mobile/1.0');
 }
Example #23
0
 public function root(DOMElement &$root)
 {
     $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:geo', 'http://www.google.com/geo/schemas/sitemap/1.0');
 }
Example #24
0
 public function root(\DOMElement &$root)
 {
     $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:news', 'http://www.google.com/schemas/sitemap-news/0.9');
 }
 private function setAttributeOnNode(\DOMElement $node, $name, $value, $namespace = null)
 {
     if (null !== $namespace) {
         if (!($prefix = $node->lookupPrefix($namespace))) {
             $prefix = 'ns-' . substr(sha1($namespace), 0, 8);
         }
         $node->setAttributeNS($namespace, $prefix . ':' . $name, $value);
     } else {
         $node->setAttribute($name, $value);
     }
 }
Example #26
0
 /**
  * Wrapper to namespace aware DOMElement::setAttributeNS with additional entities support
  *
  * @param string  $ns            namespace attribute should be in
  * @param string  $attr          Attribute name to set
  * @param string  $value         Value to set attribute to
  * @param bool    $keepEntities  Flag to signale if entities should be kept
  *
  * @throws fDOMException
  *
  * @return \DOMAttr|null
  * @see DOMElement::setAttribute()
  */
 public function setAttributeNS($ns, $attr, $value, $keepEntities = false)
 {
     if ($keepEntities === true) {
         $attrNode = $this->ownerDocument->createAttributeNS($ns, $attr);
         if (!$attrNode) {
             throw new fDOMException("Setting attribute '{$attr}' failed.", fDOMException::SetFailedError);
         }
         $attrNode->value = $value;
         $this->appendChild($attrNode);
         return $attrNode;
     }
     return parent::setAttributeNS($ns, $attr, $value);
 }
Example #27
0
 /**
  * Converts CSS styles directly without value conversion.
  *
  * This method receives a $targetProperty DOMElement and converts the given 
  * style with $styleName and $styleValue to attributes on this 
  * $targetProperty.
  * 
  * @param DOMElement $targetProperty 
  * @param string $styleName 
  * @param ezcDocumentPcssStyleValue $styleValue 
  */
 public function convert(DOMElement $targetProperty, $styleName, ezcDocumentPcssStyleValue $styleValue)
 {
     $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_FO, "fo:{$styleName}", $styleValue->value);
 }
Example #28
0
 /**
  * 递归完成由数组创建XML 
  * 
  * @param DOMDocument $dom 
  * @param DOMElement $node
  * @param array $data 
  * @param string $format 
  * @access protected
  * @return void
  */
 protected static function _fromArray($dom, $node, &$data, $format)
 {
     if (empty($data) || !is_array($data)) {
         return;
     }
     foreach ($data as $key => $value) {
         if (is_string($key)) {
             if (!is_array($value)) {
                 if (is_bool($value)) {
                     $value = (int) $value;
                 } else {
                     if ($value === null) {
                         $value = '';
                     }
                 }
                 $isNamespace = strpos($key, 'xmlns:');
                 if ($isNamespace !== false) {
                     $node->setAttributeNS('http://www.w3.org/2000/xmlns/', $key, $value);
                     continue;
                 }
                 if ($key[0] !== '@' && $format === 'tags') {
                     $child = null;
                     if (!is_numeric($value)) {
                         $child = $dom->createElement($key, '');
                         $child->appendChild(new DOMText($value));
                     } else {
                         $child = $dom->createElement($key, $value);
                     }
                     $node->appendChild($child);
                 } else {
                     if ('@' === $key[0]) {
                         $key = substr($key, 1);
                     }
                     $attribute = $dom->createAttribute($key);
                     $attribute->appendChild($dom->createTextNode($value));
                     $node->appendChild($attribute);
                 }
             } else {
                 if ($key[0] === '@') {
                     require_once PATH_DSWAN_LIB . 'xml/sw_xml_exception.class.php';
                     throw new sw_xml_exception('Invalid array', '000100010012');
                 }
                 if (is_numeric(implode('', array_keys($value)))) {
                     // List
                     foreach ($value as $item) {
                         $itemData = compact('dom', 'node', 'key', 'format');
                         $itemData['value'] = $item;
                         self::_createChild($itemData);
                     }
                 } else {
                     self::_createChild(compact('dom', 'node', 'key', 'value', 'format'));
                 }
             }
         } else {
             require_once PATH_DSWAN_LIB . 'xml/sw_xml_exception.class.php';
             throw new sw_xml_exception('Invalid array', '000100010012');
         }
     }
 }
 /**
  * Adds namespace attributes to the XML root element
  *
  * @param \JMS\Serializer\Metadata\ClassMetadata $metadata
  * @param \DOMElement $element
  */
 private function addNamespaceAttributes(ClassMetadata $metadata, \DOMElement $element)
 {
     foreach ($metadata->xmlNamespaces as $prefix => $uri) {
         $attribute = 'xmlns';
         if ($prefix !== '') {
             $attribute .= ':' . $prefix;
         }
         $element->setAttributeNS('http://www.w3.org/2000/xmlns/', $attribute, $uri);
     }
 }
Example #30
0
 /**
  * Converts CSS 'margin' style.
  *
  * This method receives a $targetProperty DOMElement and converts the given 
  * style with $styleName and $styleValue to attributes on this 
  * $targetProperty.
  * 
  * @param DOMElement $targetProperty 
  * @param string $styleName 
  * @param ezcDocumentPcssStyleValue $styleValue 
  */
 public function convert(DOMElement $targetProperty, $styleName, ezcDocumentPcssStyleValue $styleValue)
 {
     foreach ($styleValue->value as $type => $measure) {
         $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_FO, "fo:margin-{$type}", $measure === null ? '0mm' : "{$measure}mm");
     }
 }