#253 docutils_xml writer allows to wrong XML file creation

sandbox
closed-fixed
nobody
None
5
2015-02-16
2014-04-11
Bart
No

I haven't used docutils itself. It came out while using sphinx. It creates XMLs usingdocutils_xml writer.

Way to reproduce with sphinx 1.2.2 is:
./sphinx-build.py -b xml Python-2.7.6/Doc dest
ran on Python docs source.
As a result it creates beforementioned wrong XMLs:
dest/library/functions.xml
or
dest/library/stdtypes.xml

The error is using attribute key without value, while XML spec forbids it:
http://www.w3.org/TR/xml/#sec-starttags

Please look at https://bitbucket.org/birkenfeld/sphinx/issue/1450/xml-builder-creates-invalid-xml-file to see example xml line with error, with explanation from sphinx specialist.

Discussion

  • the erronous xml::

    <desc_signature class="" first="False" fullname="abs" ids="abs" module names="abs">
    

    xml seams to require a value.

    the code producing the error ::

    for name, value in self.attlist():
        if value is None: # boolean attribute
            parts.append(name)
            continue
    

    to me None is not boolean, boolean is True/False or maybe 0/1

    to me "module" looks like yes it is a module
    and "" like no it is not.

    Having a value None says no value , therefore "module " seams reasonable to me.
    If I want 'module=""' I would assign a value.

    More important who relies on which form of output

     
  • for valueless attributes xhtml recommends the name being used as the value::

    module="module"
    

    although opera recognizes::

    <select multiple="false">
    

    as multiple being not set

     
    Last edit: engelbert gruber 2014-06-09
  • Günter Milde
    Günter Milde
    2015-02-16

    Fixed in SVN-repo.

     
  • Günter Milde
    Günter Milde
    2015-02-16

    • status: open --> closed-fixed