lodo1995 / experimental.xml

A replacement of Phobos std.xml
https://lodo1995.github.io/experimental.xml
Boost Software License 1.0
20 stars 8 forks source link

"<tag></tag>" parsed as if it were nothing #41

Open jmdavis opened 7 years ago

jmdavis commented 7 years ago

This test fails

auto xml = `<?xml version="1.0" encoding="UTF-8"?><tag></tag>`;
auto domBuilder = lexer(xml).parser().cursor().domBuilder();
domBuilder.buildRecursive();
auto dom = domBuilder.getDocument();
assert(dom.childNodes.length == 1); // length is actually 0

This succeeds

auto xml = `<?xml version="1.0" encoding="UTF-8"?><tag/>`;
auto domBuilder = lexer(xml).parser().cursor().domBuilder();
domBuilder.buildRecursive();
auto dom = domBuilder.getDocument();
assert(dom.childNodes.length == 1);

as does this

auto xml = `<?xml version="1.0" encoding="UTF-8"?><tag>foo</tag>`;
auto domBuilder = lexer(xml).parser().cursor().domBuilder();
domBuilder.buildRecursive();
auto dom = domBuilder.getDocument();
assert(dom.childNodes.length == 1);

Also, adding attributes to the opening tag in the first example has no effect. It still fails.

So, something funny is going on when there's an open and closing tag with nothing between them, and attributes don't seem to have any impact on what's going on.

wilzbach commented 6 years ago

This issue was moved to dlang-community/experimental.xml#16