Open syll-dev opened 7 months ago
Both parse-to-list
and parse
are supposed to honor the :quash-errors
flag. Presumably they should both treat nil
in the same way. @robert-dodier convinced me that it wasn't clear whether XML parsing should accept the empty document or not. That is why (parse "iueiueieiueiu" :quash-errors nil)
returns nil
, instead of raising an error, I believe.
If that is the case, then it seems to me that parse-to-list
should behave the same and accept empty XML documents.
I will see about a quick MR.
See #19
@robert-dodier Is this the change we expected? It seems reasonable to me that (parse "")
should return nil
instead of signaling an error. But shouldn't a non-XML string raise an error (at least if :quash-errors
is nil
)?
@rpgoldman I'm afraid I don't understand what "this" refers to. At any rate, I agree that a non-XML string should raise an error when :quash-errors
is nil
.
I think what I was arguing for, some time ago, is to stretch the JSON spec to say that an empty document is valid, and the parser returns nil
for that. That's noncompliant, but XMLS already has another noncompliant behavior, namely to allow multiple objects in a document. I was suggesting that it's more useful to allow both noncompliant behaviors, as opposed to enforcing the spec more carefully and disallowing both. However, if that noncompliance causes headaches in some way, it's okay by me to enforce compliance. I'm not sure where the present discussion falls in all this.
Yes, that’s what I was referring to. We were making it so that empty (or multiple?) documents were OK, and I think I may have inadvertently made it so a string of gibberish was also ok.
I haven’t used XMLS in ages, so none of this is fresh in my memory.
Sounds like it’s ok to fix it so that an error is raised for a non-XML string. Thanks
(parse-to-list str) is equivalent to (node->nodelist (parse str)).
if (parse str) fails to read the xml document and returns nil, parse-to-list fails with an unclear error message :
The result is the same with this call :
Could replacing handler-case with ignore-errors in function parse fix the problem ?
Is this the intended behaviour ?
Should
(node->nodelist nil)
returnnil
? It fails with the error above for now.When
parse
returnsnil
, shouldparse-to-list
returnnil
?Should
(parse-to-list nil)
be strictly equivalent to(node->nodelist (parse str))
for convenience or return nil / signal a clearer error whenparse
returnsnil
?