Edgewall Software

Opened 11 years ago

Closed 8 years ago

#235 closed defect (wontfix)

"lang" attribute not allowed in XHTML 1.1

Reported by: jmillikin@… Owned by: cmlenz
Priority: minor Milestone:
Component: Serialization Version: 0.5
Keywords: Cc:


In 0.5, the xml:lang attribute is copied to the lang attribute. However, in XHTML 1.1 this causes validation errors because lang is no longer allowed. The XHTML serializer should check which doctype is being serialized to before copying this attribute, or maybe even remove copying it from the XHTML serializer entirely (leave it in for HTML).

Attachments (1)

Genshi-0.6-lang.patch (1.1 KB) - added by Bjorn@… 8 years ago.
I propose this patch.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 11 years ago by cmlenz

  • Version changed from devel to 0.5

For XHTML 1.1 you should probably just be using the XML serializer, as you're giving up compatibility with HTML anyway. Or is there some feature provided by XHTML serialization in Genshi that is desirable for XHTML 1.1 output?

comment:2 Changed 11 years ago by jmillikin@…

That's the solution I ended up using, but having the XHTML serializer write invalid XHTML is confusing enough that I figured it warrented a ticket.

comment:3 Changed 9 years ago by Carsten Klein <carsten.klein@…>

Why not simply transform to xml:lang instead. It is supported by both XHTML1.0 and XHTML1.1.

comment:4 Changed 9 years ago by Carsten Klein <carsten.klein@…>

Here is a proposed patch for the XHTMLSerializer that will transform existing lang attributes to xml:lang and will output xml:lang whenever there is a xml:lang attrib avail.

It also takes care of the rule that whenever xml:lang is available it takes over precedence above any existing lang attributes, see http://www.w3.org/TR/xhtml1/#C_7

It also fixes the "bug" that when xml:lang was added to the buffer in the elif branch, it would be added a second time at the end of the if-elif statement.

  • output.py

    347355                for attr, value in attrib:
    348356                    if attr in boolean_attrs:
    349357                        value = attr
    350                     elif attr == 'xml:lang' and 'lang' not in attrib:
    351                         buf += [' lang="', escape(value), '"']
     358                    elif attr == 'lang' and 'xml:lang' not in attrib:
     359                        attr = 'xml:lang'
    352360                    elif attr == 'xml:space':
    353361                        continue
    354362                    buf += [' ', attr, '="', escape(value), '"']

comment:5 Changed 8 years ago by Bjorn@…

I have this problem, also in Genshi 0.6, except that I'm using XHTML+RDFa 1.0 in the pages I generate. The lang attribute isn't allowed in XHTML+RDFa 1.0. There seems to be a plan to include it in XHTML+RDFa 1.1, but I don't want to use that until it becomes a recommendation.

I tried the XML serializer, but then Explorer wouldn't display the generated pages. I have some empty script elements in my templates (pointing to separate Javascript files), and apparently Explorer doesn't understand that a script element is closed when it's represented as an empty tag instead of a start tag and an end tag, so it thinks the entire rest of the page is Javascript. Firefox and Seamonkey do the same if the pages are served as text/html, but display them correctly if served as application/xhtml+xml. With Explorer, application/xhtml+xml doesn't help. As much as I loathe being bug compatible with programs that won't follow standards, I do want even users of Explorer to be able to see my pages.

I think the right thing to do is to simply pass attributes through from the input to the output, and let users add both lang and xml:lang explicitly if they want both.

Changed 8 years ago by Bjorn@…

I propose this patch.

comment:6 Changed 8 years ago by anonymous

XHTML1.1 was updated in 2010 to add the lang attribute back. I'm inclined to close this as "won't fix" unless someone presents a strong practical need to change Genshi's behaviour to comply with outdated versions of the XHTML1.1 specification.

See "Status of this document" in http://www.w3.org/TR/2010/REC-xhtml11-20101123/ for a mention of this update to XHTML1.1.

comment:7 Changed 8 years ago by jmillikin@…

  • Resolution set to wontfix
  • Status changed from new to closed

Sounds reasonable. As long as Genshi's behavior matches the spec, it doesn't matter to me which one changed.

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain cmlenz.
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.