This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 5847 - <html lang="en" xml:lang="en" ... reported as missing lang attribute
Summary: <html lang="en" xml:lang="en" ... reported as missing lang attribute
Status: RESOLVED FIXED
Alias: None
Product: mobileOK Basic checker
Classification: Unclassified
Component: Java Library (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Abel Rionda
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-09 21:01 UTC by Olivier Thereaux
Modified: 2008-07-16 09:29 UTC (History)
2 users (show)

See Also:


Attachments

Description Olivier Thereaux 2008-07-09 21:01:39 UTC
Testing a page in the mobileOK checker with the following markup start:

<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
...

Will yield the following error in the markup test:
Attribute "lang" must be declared for element type "html"

Whereas it should ideally be something like: 
Attribute "lang" is not allowed in XHTML-MP 1.2 for the <html> element. Use only xml:lang.

I saw this bug in both ready.mobi and http://validator.w3.org/mobile/
Comment 1 Abel Rionda 2008-07-10 07:07:18 UTC
This seems to be out of our control since this message is reported by the SAX Parser that we use in our code.
(Unfortunately,We do not have access to the message string that SAX uses internally)
Comment 2 Olivier Thereaux 2008-07-10 13:14:54 UTC
(In reply to comment #1)
> This seems to be out of our control since this message is reported by the SAX
> Parser that we use in our code.

I know that kind of problem :), but disagree the only way forward is WONTFIX and burying the issue. It will come back and bite again.

I could suggest either:
* intercepting that string from the SAX parser and replacing with something more useful
* escalating the bug report to the makers of that SAX parser
or both.

(or alternatively look at other markup validating solutions than that parser?)
Comment 3 fd 2008-07-16 09:29:07 UTC
I had a look at the underlying library.
The problem arrises in the:
com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator class.

2 messages seems to be causing troubles, identified by their 'key':
- MSG_ATTRIBUTE_NOT_DECLARED
- MSG_ELEMENT_NOT_DECLARED

I guess that, by "must be declared", the messages intend to mean that the element/attribute must be declared in the dtd before they can be used. I guess not a single user would reason using that point of view, so the messages should definitely be changed.

I could not find the messages strings, defined in:
 com.sun.org.apache.xerces.internal.impl.msg.XMLMessages
I suppose the sources are not public.
In particular, I couldn't check if the same message strings may be used for other reasons than this particular use case. What is sure is that the MSG_ATTRIBUTE_NOT_DECLARED and MSG_ELEMENT_NOT_DECLARED messages keys are only used for that purpose.

I implemented a "brute force" workaround in our XHTMLValidationErrorHandler class that:
1. replaces
 'Attribute "[attribute]" must be declared for element type "[element]".'
by
 'Attribute "[attribute]" is not allowed for element type "[element]".'

2. replaces:
 'Element type "[element]" must be declared.'
by
 'Element type "[element]" is not allowed.'

I committed the change and updated the test suites results that failed because of that particular change.