SWI-Prolog / packages-sgml

The SWI-Prolog SGML/XML/HTML parser
5 stars 9 forks source link

Do not consider namespaces missing if they are already emitted in kee… #34

Closed thetrime closed 4 years ago

thetrime commented 4 years ago

…p_prefix mode

Without this, you get

?- xml_write(user_error, element(ns(foo, 'http://www.example.com'):bar, [], [element(ns(foo, 'http://www.example.com'):baz, [], [])]), []).
<?xml version="1.0" encoding="UTF-8"?>

<foo:bar
    xmlns:xns22="http://www.example.com"
    xmlns:xns21="http://www.example.com">
  <foo:baz/>
</foo:bar>
true.

With the patch, you get

<foo:bar xmlns:xns19="http://www.google.com">
  <foo:baz/>
</foo:bar>

I think this might still be wrong, but it's not as wrong?

thetrime commented 4 years ago

Actually it's plenty wrong. The right answer, is, of course

<foo:bar xmlns:foo="http://www.google.com">
  <foo:baz/>
</foo:bar>

I'll keep digging here

thetrime commented 4 years ago

Ok, I think this looks right now. At least, it works for my test case, and it still generates the right thing when removing the ns/2 from the test case.

JanWielemaker commented 4 years ago

Thanks. Merged after squash and edit of commit message.