SWI-Prolog / packages-sgml

The SWI-Prolog SGML/XML/HTML parser
4 stars 10 forks source link

How to parse XML short tags? #23

Closed wouterbeek closed 5 years ago

wouterbeek commented 5 years ago

I have not been able to parse XML short tags without warnings.

For this example XML document:

<?xml version="1.0" encoding="UTF-8"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
  <head>
    <variable name="x"/>
  </head>
  <results>
    <result>
      <binding name="x"><uri>https://example.org/</uri></binding>
    </result>
  </results>
</sparql>

Is explicitly specify the shorttag/1 option:

?- use_module(library(sgml)).
?- load_xml('test.xml', Dom, [shorttag(true)]).

And still receive the following warning:

Warning: SGML2PL(xml): test.xml:5: Inserted omitted end-tag for "variable"

Is this option broken of am I doing something wrong?

JanWielemaker commented 5 years ago

Still isn't the right word. Without this option load_xml/3 load the file fine. The shorttag concept refers to '<b/hello/', an SGML shorthand for 'hello` (well, I do not know how to avoid Github considering this markup, but you get the point, I guess).

The shorttag option should probably be denied for xml mode, although combining options can give you opportunities to process invalid documents.

wouterbeek commented 5 years ago

Oops, I had completely misinterpreted the purpose of that option :-/