pfalcon / pycopy-lib

Standard library of the Pycopy project, minimalist and light-weight Python language implementation
https://github.com/pfalcon/pycopy
Other
246 stars 70 forks source link

xml.etree.ElementTree can't handle some elements. #58

Open water5 opened 4 years ago

water5 commented 4 years ago

I try to let it handle some actual xml feed document, it seems can't handle none pairs type XML dedicated elements, e.g.

<?xml version="1.0" encoding="utf-8" ?> will arise :

Traceback (most recent call last): File "", line 1, in File "/lib/ElementTree.py", line 130, in fromstring File "/lib/ElementTree.py", line 108, in parse_el IndexError: list index out of range

CDATA Sections https://www.w3.org/TR/REC-xml/#sec-cdata-sect <channel><item><cdata_section><![CDATA[something to test.]]></cdata_section></item></channel> will arise:

Traceback (most recent call last): File "", line 1, in File "/lib/ElementTree.py", line 130, in fromstring File "/lib/ElementTree.py", line 94, in parse_el File "/lib/xmltok2.py", line 131, in tokenize File "/lib/xmltok2.py", line 96, in expect XMLSyntaxError:

One of actual XML document: https://www.w3.org/blog/news/feed

Is it possible improve it ?

pfalcon commented 4 years ago

<?xml version="1.0" encoding="utf-8" ?> will arise : IndexError: list index out of range

Yes, I noticed that too, that's addressed in the pycopy-xml.etree.ElementTree 0.2.1, just released.

CDATA Sections will arise:

Yes, CDATA is not supported yet, as can be seen, it's not recognized on the level of tokenizer (xmltok2).

Is it possible improve it ?

Sure. The whole of pycopy-lib is developed in incremental way based on the needs of its users. Simple, clean patches adhering to the project guidelines/aims (https://github.com/pfalcon/pycopy-lib/blob/master/CONTRIBUTING.md , https://github.com/pfalcon/pycopy-lib/blob/master/README.md) are always welcome.