alcamo/xpointer

Implementation of XPointer framework with xmlns() and xpointer() schemes

Installs: 141

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/alcamo/xpointer

0.8.0 2025-10-07 18:01 UTC

This package is auto-updated.

Last update: 2025-10-07 18:13:21 UTC


README

use alcamo\xpointer\Pointer;

$doc = new \DOMDocument();

... load something into the document ...

$urlFragment = 'xmlns(f=http://foo.example.org) xpointer(/*/f:bar[42])';

$pointer = new Pointer($urlFragment);

The following evaluates the XPath /*/f:bar[42] on the document, where the prefix f is registered as the namespace http://foo.example.org:

$bar = $pointer->process($doc);

Supplied interfaces and classes

Interface PointerInterface

Simple interface for classes that implement a Pointer. Requires a static factory method to create a Pointer from an URL fragment string and a method to process the pointer on a DOM document.

Class Pointer

Implementation of PointerInterface supporting Shorthand Pointers as well as the XPointer xmlns() Scheme and XPointer xpointer() Scheme.

Interface PartInterface

Simple interface for classes that implement a Pointer part. Requires just a process() method to process the Scheme data. Processing of parts stops as soon as this method return a non-null value.

Class XmlnsPart

Implementation of PartInterface for the XPointer xmlns() Scheme. The process() method modifies the namespace bindings as described in the specification.

Class XpointerPart

Implementation of PartInterface for the XPointer xpointer() Scheme. The process() method returns the result of XPath evaluation, if successful.

Extending this package

To add other XPointer schemes:

  1. Write a new pointer part class that implements PartInterface.
  2. Write a class derived from Pointer and add your new pointer part class to the class constant SCHEME_MAP.