Hi, Rust developers!
I have been implementing an XML SAX parser in pure Rust. It was my first serious Rust project so it was educational as well as enjoyable.
The interesting idea in my parser is that I have separated interface and implementation.
I work as an enterprise integration consultant. In the Java world where XML is a first-class citizen, there is one interface and many implementations for XML parsers. I think there is a big intersection between people who use XML daily and people exposed to Java. So I tried to get inspiration from the SAX interface. The decision is like rust's choice of being C-style. I think it will be easier for users with familiarity.
I have been able to parse a 3.5 GB XML file on an amazon micro instance with 1 GB ram and I think it is very fast(release) for common usage.(Benchmarks needed)
I'm open to your ideas about improving both Rust code and API. I'm also eager to chat and work with XML parser implementors on the SAX interface.
Beware that the libraries are not feature-complete yet.
Here is an example usage:
Updated to version v0.0.4 with attribute name&value support. You can use iterator with attributes! Next step should be namespace support.
The library should work fine with well-formed documents. However, error handling is harder with my parser implementation. I think standardized error codes and messages would be great in the future.
I explore the validity of interface(xml_sax) with implementation(xml_oxide). I can change implementation when interface matures. I am always open to ideas.
Thanks for your support & interest!
Updated library to version v0.0.5
- Internal changes to the parser, SAX interface doesn't change so my unit tests are not affected.
- Minimum RAM usage (it removes chars from memory after tags pass).
- High CPU usage (this is not a feature! )
To-do list include:
- Making SAX namespace aware
- Ensuring SAX Interface is beautiful so that it gets community acceptance. I need help & opinions here!
- Write SAX adapter libraries for other XML parsers. (This is one benefit of interface library)
In my vision these libraries could provide code reuse across community if they get community acceptance.
(any xml parser implementation) => XML SAX Interface => XML DOM Interface(trait + objects?) => XSD,XSLT,WSDL,Mapping libraries/applications
This ensures applications/libraries can change underlying implementations easier.
Thank you for reading.
I have just updated library to version v0.0.6 and xml_sax interface library to v0.0.3
- Namespace support, finally!
- ContentHandler seems to be fully implemented. Maybe I can implement start/end prefix mapping but that is a nice-to-have for now. I'm open to ideas. Especially if you have ideas about interface library, the sooner we discuss the better
- Write SAX adapter libraries for other XML parsers.
- Develop new backends using the nice parser libraries like nom & pest.
- More documentation
- Library cleaning & trying to apply best practices(learning from the community)
Thank you for reading.