[Django] #33117: sitemap.xml template used with alternates for multiple languages returns an invalid xml

45 views
Skip to first unread message

Django

unread,
Sep 17, 2021, 11:11:51 AM9/17/21
to django-...@googlegroups.com
#33117: sitemap.xml template used with alternates for multiple languages returns an
invalid xml
--------------------------------------------+------------------------
Reporter: ViggieSmalls | Owner: nobody
Type: Bug | Status: new
Component: contrib.sitemaps | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
--------------------------------------------+------------------------
The generated xml has following validation error: "Error 1845: Element
'{http://www.w3.org/1999/xhtml}link': No matching global element
declaration available, but demanded by the strict wildcard."

This [https://stackoverflow.com/a/43502548/5540654 response] in
StackOverflow contains the correct fix.

The error in the `sitemap.xml` template error is simply a missing slash
for `xmlns:xhtml="http://www.w3.org/1999/xhtml/"`
[https://github.com/django/django/blob/4ca508a68916dd43da45fd6e8b9004824a62d9c8/django/contrib/sitemaps/templates/sitemap.xml#L2
in line 2].

--
Ticket URL: <https://code.djangoproject.com/ticket/33117>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 20, 2021, 12:47:57 AM9/20/21
to django-...@googlegroups.com
#33117: sitemap.xml template used with alternates for multiple languages returns an
invalid xml
----------------------------------+--------------------------------------
Reporter: Viggie | Owner: nobody

Type: Bug | Status: new
Component: contrib.sitemaps | Version: 3.2
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* cc: Carlton Gibson, Florian Demmer (added)


Comment:

"http://www.w3.org/1999/xhtml/" without a trailing slash should be
completely valid. Florian, Can you take a look?

--
Ticket URL: <https://code.djangoproject.com/ticket/33117#comment:1>

Django

unread,
Sep 20, 2021, 3:54:12 AM9/20/21
to django-...@googlegroups.com
#33117: sitemap.xml template used with alternates for multiple languages returns an
invalid xml
----------------------------------+--------------------------------------
Reporter: Viggie | Owner: nobody

Type: Bug | Status: new
Component: contrib.sitemaps | Version: 3.2
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------------------+--------------------------------------

Comment (by Florian Demmer):

What validator was used to produce this error?

Not only is the namespace name "http://www.w3.org/1999/xhtml" valid, the
name "http://www.w3.org/1999/xhtml/" (with trailing slash) would be a
different namespace.

As specified in [https://www.w3.org/TR/REC-xml-names/#NSNameComparison 2.3
Comparing URI References]:

URI references identifying namespaces are compared when determining
whether a name belongs to a given namespace, and whether two names belong
to the same namespace. [Definition: The two URIs are treated as strings,
and they are identical if and only if the strings are identical, that is,
if they are the same sequence of characters. ] The comparison is case-
sensitive, and no %-escaping is done or undone.

and [https://www.w3.org/TR/REC-xml-names/#ns-decl 3 Declaring Namespaces]:

The namespace name, to serve its intended purpose, SHOULD have the
characteristics of uniqueness and persistence. It is not a goal that it be
directly usable for retrieval of a schema (if any exists).

The namespace name for XHTML is specified [https://www.w3.org/1999/xhtml/
here]:

The namespace name http://www.w3.org/1999/xhtml is intended for use in
various specifications such as: [...]

Therefore I conclude, that the validator and the StackOverflow
recommendations are wrong and nothing should be changed in the
{{{sitemap.xml}}} template.

--
Ticket URL: <https://code.djangoproject.com/ticket/33117#comment:2>

Django

unread,
Sep 20, 2021, 4:10:12 AM9/20/21
to django-...@googlegroups.com
#33117: sitemap.xml template used with alternates for multiple languages returns an
invalid xml
----------------------------------+--------------------------------------
Reporter: Viggie | Owner: nobody
Type: Bug | Status: closed
Component: contrib.sitemaps | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0

----------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid
* easy: 1 => 0


Comment:

Florian, thanks for checking!

--
Ticket URL: <https://code.djangoproject.com/ticket/33117#comment:3>

Reply all
Reply to author
Forward
0 new messages