delb-xml / delb-py

A library that provides an ergonomic model for XML encoded text documents (e.g. with TEI-XML).
https://delb.readthedocs.io
GNU Affero General Public License v3.0
16 stars 0 forks source link

Add accessors to leading and tailing nodes #2

Closed funkyfuture closed 4 years ago

funkyfuture commented 5 years ago

XML markup can contain a subset of node types (comments, PIs, maybe CDATA) before and after the root node (which is always a TagNode). at the moment these might only be accessible by fetching siblings from the root node, i'm not sure though.

i propose to add two properties to the Document class: head_nodes and tail_nodes that should mostly behave like lists (with an additional prepend method).

i'm not sure whether or not it should be possible to 'hop' from the last / first items in these to the root node (with next_node and previous_node) and vice versa.

funkyfuture commented 4 years ago

implemented in 29a41735e96b9df8f381e1dad2ebd4ac33b376f0