/** * Special helper for namespaced tags. * * @param object $element The tag are adding a new namespaced element to * @param string $tag the tag name, possibly prefixed with the namespace * @param mixed $content The content of the tag * @param array $attributes An array of key/value pairs of attributes. * @param string $namespace The namespace for the tag * */ function NSElement(&$element, $in_tag, $content = false, $attributes = false, $namespace = null) { if ($namespace == null && preg_match('/^(.*):([^:]+)$/', $in_tag, $matches)) { $namespace = $matches[1]; if (preg_match('{^[A-Z][A-Z0-9]*$}', $namespace)) { throw new Exception("Dodgy looking namespace from '" . $in_tag . "'!"); } $tag = $matches[2]; } else { $tag = $in_tag; if (isset($namespace)) { $tag = str_replace($namespace . ':', '', $tag); } } if (isset($namespace) && !isset($this->namespaces[$namespace])) { $this->AddNamespace($namespace); } return $element->NewElement($tag, $content, $attributes, $namespace); }
/** * Special helper for namespaced tags. * * @param object $element The tag are adding a new namespaced element to * @param string $tag the tag name, possibly prefixed with the namespace * @param mixed $content The content of the tag * @param array $attributes An array of key/value pairs of attributes. * @param string $namespace The namespace for the tag * */ function NSElement(&$element, $in_tag, $content = false, $attributes = false, $namespace = null) { if ($namespace == null && preg_match('/^(.*):([^:]+)$/', $in_tag, $matches)) { $namespace = $matches[1]; $tag = $matches[2]; } else { $tag = $in_tag; } if (isset($namespace) && !isset($this->namespaces[$namespace])) { $this->AddNamespace($namespace); } return $element->NewElement($tag, $content, $attributes, $namespace); }