-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/xml stream parser #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
5368e1e to
d86737e
Compare
d86737e to
2630191
Compare
|
|
||
| decode!Value(`<Value><A a="5"/><B b="3"/></Value>`).should.throwAn!XmlException | ||
| (`Element "Value": contained more than one of "A", "B"`); | ||
| (`"this.builder.field": found more than one kind of element of "A", "B" in [A(5), B(3)]`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message with “element” and “kind” and “[]” looks rather cryptic.
xmllint complains in the first case that A or B is missing.
And in the second case that B is not expected. The choice is made by the first A.
| } | ||
|
|
||
| // when | ||
| auto value = decode!Container(`<Container> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that namespaces are difficult. In the root element they are declared like this:
xmlns:ns2="http://www.ifopt.org.uk/acsb" xmlns:ns3="http://www.ifopt.org.uk/ifopt" xmlns:ns4="http://datex2.eu/schema/2_0RC1/2_0"
Here, ns2, ns3, ns4 could also be foo, bar, baz. Then ns2:MobilityImpairedAccess actually stands for {http://www.ifopt.org.uk/acsb}MobilityImpairedAccess.
If the deserializer does not support this, a delimiting comment would be appropriate.
| module text.xml.Decode; | ||
|
|
||
| import boilerplate.util : udaIndex; | ||
| import boilerplate.util : optionallyRemoveTrailingUnderline, udaIndex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problematic function name has already been introduced with boilerplate. There, the function requires a comment...
I would have preferred what instead of how. Claude suggests normalizeFieldName, for example. Then the detail of whether the underscore is added to the front or back, or whether we put "a" or "my" in front of the field name, remains a boilerplate secret.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW: "enum field with underscore" is the test case for optionallyRemoveTrailingUnderline
(the "underline" instead of "underscore" was what made me stumble over the meaningfulness of the function name)
What's the matter with foo_? If there is another enum member foo?
Switch XML decoder to stream parsing.