public registerNamespace ( string $prefix, string $namespace ) | ||
$prefix | string | |
$namespace | string |
public function registerNamespace($prefix, $namespace)
{
$prefix = $this->validatePrefix($prefix);
if (isset($this->_reserved[$prefix])) {
throw new \LogicException(sprintf('Can not register reserved namespace prefix "%s".', $prefix));
}
$this->_namespaces[$prefix] = $namespace;
if (isset($this->_xpath) && $prefix !== '#default') {
$this->_xpath->registerNamespace($prefix, $namespace);
}
}
/** * Create and return a JSONx document. * * @return Document */ public function getDocument() { $document = new Document(); $document->registerNamespace('json', self::XMLNS_JSONX); $this->addNode($document, $this->_document->documentElement); return $document; }