Add Instructions for reading and writing XML
For the record, where do you draw the line between features that should be extra packages instead of merged into the standard library?
This adds instructions for reading and writing XML, supporting whitespace and meta nodes. I've been using this for basic XML processing, where an XSLT transformer would be excessive.
xml.dumps example:
> :{"foo":name; [:{"bar":name;}]:content;} :(xml.dumps)
"<foo><bar/></foo>"
xml.loads example:
> "<list><item>1</item><item>2</item></list>" :(xml.loads)
:{
0:meta;
"list":name;
[ ]:attributes;
[
:{
0:meta;
"item":name;
[ ]:attributes;
[ "1" ]:content;
}
:{
0:meta;
"item":name;
[ ]:attributes;
[ "2" ]:content;
}
]:content;
}
It's a bit clunky to use / I had to fight the standard library to get this to work. But it's better than Regex.
I'd like to make this a bit more robust for rewriting existing Xml. (Mainly preserving whitespace between attributes and better support for entity references (e.g. ))
Though I cannot use the builtin parsers / serializers for this, so it'll be a bit of a rewrite.
This is great, thanks for putting it together.
For the record, where do you draw the line between features that should be extra packages instead of merged into the standard library?
I don't have a formal definition at this point. Practically speaking, it is nice to have some of the more common tools easily accessible in the language and I'm not too worried about limiting the :(...) style operators at this point. So, if it is in the standard library of languages with big standard libraries like Python or Ruby, then I think it is fine to keep in the standard library here.
Disable truncating in important strings (106b6040beddcbe94afe7df25cfd27e042b8a5fa and 348006b7dd3a67a8cf3fb579ba005e2736720b2a)
Disables truncating in
- lists (relevant for import errors, which prints a list of candidate files)
- assert errors
Publish a runtime artifact (3de22299db92fd430f83034981a48d453ad62c8c)
This contains files required for running aya. (ayarc.aya, base/*.aya and std/*.aya)
That way, package developers can run 'pkg.test' in their build process. (Unfortunately this doesn't quite work yet, since aya is not available in any public maven repository) (The current workaround/hack is to build aya from source, like this)
Redesign the Xml instructions to be easier to use (3301811e41bfd1c23847dfa6045c5a2637a8b386)
With the old instructions, I tried to push too many usecases onto a single instruction.
The new instructions focus on extracting/writing data with as little friction as possible. They're heavily inspired by this python package https://pypi.org/project/xmltodict/
This package https://github.com/BlazingTwist/xml.aya (WIP) will cover more advanced usages, such as modifying existing documents, extracting data with xPath expressions, reading data from comments/processing-instructions, or validating against an XSD.