GSoC 2016 - std.experimental.xml after a month

Lodovico Giaretta via Digitalmars-d digitalmars-d at puremagic.com
Sat Jun 25 13:33:51 PDT 2016


On Saturday, 25 June 2016 at 20:16:09 UTC, Steven Schveighoffer 
wrote:
> When I had the gumption to try and make an XML parser range, 
> the idea I had was to have the current element's tag and 
> attributes, all parent elements' tags and attributes, and the 
> currently parsed entity inside the element. If the entity you 
> were parsing was an element, you could either popFront it, to 
> get to the next element, or descend into it's children, and the 
> element and it's attributes would be pushed onto the "element" 
> stack.
>
> The idea is to keep all the context alive, but not have to keep 
> the entire file in memory.
>
> Anyway, that's how I envisioned it. Haven't finished my i/o 
> package yet, so it didn't materialize :)
>
> -Steve

Thank you for your feedback.

You idea is similar to my Cursor API, which has next() to reach 
the next element and enter()/exit() to descend to the first child 
or ascend to the closing tag of the parent.

But my implementation does not maintain the state of the parents, 
so you can't get any info about the parent from the children, 
unless you use exit() (in which case, you can get the parent's 
name from the closing tag).

But your idea about a stack keeping all the context informations 
is quite valuable, given that some validations need them (e.g. 
checking that all prefixes have been declared, and retrieving 
prefix/namespace associations).



More information about the Digitalmars-d mailing list