Version 0.6.0
Total issues resolved: 6
- 14: Upgrade to GitHub-native Dependabot thanks to @dependabot-preview[bot]
- 15: Improved xmlns support
- 16: Add canonicalize configurator
- 17: Optimize namespaces manipulator and comparable() configurator
- 18: Add functions for renaming nodes
- 19: Improve consistency
Some highlights:
comparable() configurator
use VeeWee\Xml\Dom\Document;
use function VeeWee\Xml\Dom\Configurator\comparable;
use function VeeWee\Xml\Dom\Locator\document_element;
use function VeeWee\Xml\Dom\Mapper\xml_string;
$raw = <<<EOXML
<foo version="1.9" target="universe">
<item
a:sku="xml"
z:id="3"
xmlns:a="http://a"
xmlns:z="http://z"
>XML</item>
</foo>
EOXML;
$expected = <<<EOXML
<foo xmlns:ns1="http://z" xmlns:ns2="http://a" target="universe" version="1.9">
<item ns1:id="3" ns2:sku="xml">XML</item>
</foo>
EOXML;
$actualDoc = Document::fromXmlString($raw, comparable());
$actual = $actualDoc->map(static fn (DOMDOcument $doc) => xml_string()($doc->documentElement));
assert($actual === $expected);
xmlns
xmlns_attributes_list($element)
->filter(
static fn (DOMNameSpaceNode $xmlns): bool => (bool) $xmlns->prefix
)
->forEach(
static function (DOMNameSpaceNode $xmlns) use ($element) {
remove_namespace($xmlns, $element);
}
);
renaming
use function VeeWee\Xml\Dom\Manipulator\Attribute\rename as rename_attribute;
use function VeeWee\Xml\Dom\Manipulator\Element\rename as rename_element;
use function VeeWee\Xml\Dom\Manipulator\Xmlns\rename as rename_xmlns;
rename_attribute($attr, 'foo', $newUri);
rename_element($element, 'foo', $newUri);
rename_xmlns($doc, 'http://namespace', 'prefix');