PHP Class FluentDOM\Transformer\Namespaces\Optimize

Mostra file Open project: fluentdom/fluentdom

Public Methods

Method Description
__construct ( DOMDocument $document, array $namespaces = [] ) Create a namespace optimizer for the provided document. The provided document will be copied.
__toString ( ) : string Create a document with optimized namespaces and return it as xml string
getDocument ( ) : Document Create and return a document with optimized namespaces.

Private Methods

Method Description
addAttribute ( DOMElement $target, DOMAttr $source ) Add an attribute to the target element node.
addElement ( DOMNode $target, DOMElement $source ) Add an element node to the target (document or element)
addNamespaceAttribute ( DOMElement $node, string | null $prefix, string $uri )
addNode ( DOMNode $target, DOMNode $source ) Add a node to the target element, just copies any child nodes except elements. Element nodes are recreated with mapped/optimized namespaces.
canAddNamespaceToNode ( DOMNode $node, string | null $prefix, string $uri ) : boolean
createElement ( DOMNode $target, string $prefix, string $name, string $uri ) : DOMElement
getNodeDefinition ( DOMNode $node ) : array Get the node name definition (prefix, namespace, local name) for the target node

Method Details

__construct() public method

The second argument allows to provide namespaces and prefixes. The keys of the array are the namespace uri, the values are the prefixes. If a namespace is not provided it is read from the source node. You can use the same prefix for multiple namespace uris. Empty prefixes are possible (default namespace for an element). It is highly recommend that you always use a non-empty prefix if the here are attributes in that namespace. Attributes always need a prefix to make use of the namespace.
public __construct ( DOMDocument $document, array $namespaces = [] )
$document DOMDocument
$namespaces array

__toString() public method

Create a document with optimized namespaces and return it as xml string
public __toString ( ) : string
return string

getDocument() public method

Create and return a document with optimized namespaces.
public getDocument ( ) : Document
return FluentDOM\Document