Opened 11 years ago

Closed 10 years ago

Last modified 9 years ago

#11474 closed (duplicate)

models.XMLField doesn't work as advertised

Reported by: Jim Garrison Owned by: nobody
Component: Documentation Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


There are two errors currently in the (documentation of) models.XMLField:

  • The documentation claims that schema_path is a required argument, but it is not.
  • Regardless of whether schema_path is given, models.XMLField does not actually perform any validation. It works no differently than an ordinary TextField, succeeding even if the input is not XML at all.

Tickets #3094 and #5620 are likely related to this bug. I reference them for historical interest, since it seems that it was once assumed that #3094 would to be fixed before 1.0.

Change History (5)

comment:1 Changed 11 years ago by Alex Gaynor

Triage Stage: UnreviewedAccepted

comment:2 Changed 11 years ago by django@…

As a stopgap measure, xml.parsers.expat could be used to verify that the XML is at least well-formed, albeit perhaps not compliant with any particular schema.

For example, I currently use the following on a form that allows users to input XML in a multi-line text field:

    def clean_dialplan_xml(self):
        from xml.parsers import expat
        tmp = expat.ParserCreate()

        except expat.ExpatError, e:
            raise forms.ValidationError(e)

        return self.cleaned_data['dialplan_xml']

This could/should perhaps be instead implemented in django.db.models.fields instead.

comment:3 Changed 10 years ago by Paul McMillan

Component: Database layer (models, ORM)Documentation
milestone: 1.3

This is really a docs ticket. I'm changing the category to reflect that, so that it'll get some attention.

#3094 will be resolved whenever it gets resolved (if ever) but in the meantime the docs should reflect the way Django really functions (especially for 1.1 and 1.2 where the feature will never surface).

I suggest changing the relevant docs to read something like:

A TextField for XML. Does not currently provide any validation. Takes one optional argument:

The filesystem path to an XML schema.

In addition to posting here, I'll try and get that ticket moving as well.

comment:4 Changed 10 years ago by Gabriel Hurley

Resolution: duplicate
Status: newclosed

Closing as a duplicate of #3094. There's no point in changing the docs until that ticket is resolved. My thoughts on what the resolution should be are noted on that ticket.

comment:5 Changed 9 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top