Ejemplo n.º 1
0
 /**
  * Writes a new attribute.
  *
  * The name may be specified in clark-notation.
  *
  * Returns true when successful.
  *
  * @param string $name
  * @param string $value
  * @return bool
  */
 public function writeAttribute($name, $value)
 {
     if ($name[0] === '{') {
         list($namespace, $localName) = Util::parseClarkNotation($name);
         if (array_key_exists($namespace, $this->namespaceMap)) {
             // It's an attribute with a namespace we know
             $this->writeAttributeNS($this->namespaceMap[$namespace], $localName, null, $value);
         } else {
             // We don't know the namespace, we must add it in-line
             if (!isset($this->adhocNamespaces[$namespace])) {
                 $this->adhocNamespaces[$namespace] = 'x' . (count($this->adhocNamespaces) + 1);
             }
             $this->writeAttributeNS($this->adhocNamespaces[$namespace], $localName, $namespace, $value);
         }
     } else {
         return parent::writeAttribute($name, $value);
     }
 }
Ejemplo n.º 2
0
 /**
  * Get tag name from a Clark notation.
  *
  * @param string $clarkedTagName
  *
  * @return string
  */
 protected static function getTagName($clarkedTagName)
 {
     list(, $tagName) = SabreXml\Util::parseClarkNotation($clarkedTagName);
     return $tagName;
 }