ianprime0509 / zig-xml

XML parser for Zig
http://ianjohnson.dev/zig-xml/
BSD Zero Clause License
14 stars 3 forks source link

In-memory document parser #29

Closed ianprime0509 closed 1 week ago

ianprime0509 commented 10 months ago

The current parser options are primarily oriented towards streaming a document from a file or other reader source. However, one of the design goals behind Scanner was to additionally enable a more optimized in-memory, zero copy document parser for cases where that is feasible.

To that end, a new type can be created (one potential name is Parser) which accepts a full XML document as a slice and uses Scanner to go through the document one codepoint at a time, yielding events which can reference the underlying document rather than copying data as Reader does today. These events would reference the raw document data, so additional functions would be needed to apply transformations such as entity expansion and end-of-line normalization to the raw data if needed.

ianprime0509 commented 1 week ago

Implemented in #36 via StaticDocument.