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 3663 - If SVG content-type detected, sniff doctypeless SVG documents for version and profile.
Summary: If SVG content-type detected, sniff doctypeless SVG documents for version and...
Alias: None
Product: Validator
Classification: Unclassified
Component: check (show other bugs)
Version: 0.7.2
Hardware: PC All
: P2 normal
Target Milestone: 0.8.2
Assignee: Olivier Thereaux
QA Contact: qa-dev tracking
Depends on:
Reported: 2006-09-07 01:27 UTC by Olivier Thereaux
Modified: 2007-10-09 09:49 UTC (History)
0 users

See Also:


Description Olivier Thereaux 2006-09-07 01:27:38 UTC
SVG documents are often omitting DOCTYPE declaration (for the sake of brevity, IIRC). This is an obvious problem for validation, as it relies upon DOCTYPE declaration for the selection of the proper doctype to validate the document against.

Recent progress has been made to add SVG document types to the doctype drop-down, allowing forced validation of SVG documents without doctype declarations.

See e.g:
(targeted for 0.7.3 release)

There is an additional change that could make things more usable for users of SVG. As discussed in Bug #1500 and Bug #24, we are currently reworking some of the tools's mechanisms with regards to content-type handling.

Current mechanism is:
* check content-type
* preparse document to find a doctype
* send document to opensp, which will fallback to a default doctype if no doctype found

Proposed mechanism:
* check content-type
* preparse document to find a doctype
* if no doctype found, and content type is image/xml+svg, look for an <svg> element and its profile and version attributes
* if these are found, add the relevant doctype to the document and pass it to the parser

This will allow at least "tentative validation" of the document according to the "sniffed" document type.
Comment 1 Chris Lilley 2006-09-07 14:03:01 UTC
The proposed solution would be suitable for SVG 1.0, and 1.1 Tiny, Basic and Full.

it would not be suitable for SVG 1.2, or for compound documents such as CDI or XHTML+math+SVG. For those cases,namespace awareness is needed and DTDs are either suboptimal or clearly inappropriate.
Comment 2 Olivier Thereaux 2007-10-03 07:47:07 UTC
With Bug 857 fixed, we can now more easily add a doctype on the fly even for documents with xml declaration. 

preparse_doctype routine already looks at root element and some other attributes (e.g xmlns), we can make it look for version and baseProfile too, and add mechanism to add doctype if those are found in convincing way.
Comment 3 Olivier Thereaux 2007-10-03 08:10:54 UTC
test cases added:

Targeting resolution for 0.8.2
Comment 4 Olivier Thereaux 2007-10-03 10:45:17 UTC
Patch made and applied to CVS:

The code seems to be working for all the test cases present:

(need a tad more testing on other kinds of doctypeless docs before declaring victory)
Comment 5 Olivier Thereaux 2007-10-09 09:49:57 UTC
Closing this, while being well aware that this is only a solution for svg documents with no foreign namespace elements, etc.