Skip to content

Comments

Improve conformance by allowing 1.x as version#56

Merged
kornelski merged 3 commits intokornelski:mainfrom
drott:allow1x
Nov 15, 2025
Merged

Improve conformance by allowing 1.x as version#56
kornelski merged 3 commits intokornelski:mainfrom
drott:allow1x

Conversation

@drott
Copy link

@drott drott commented Nov 5, 2025

No description provided.

@drott
Copy link
Author

drott commented Nov 5, 2025

CC @dbaron

According to [1] an XML processor needs to accept documents
with version strings matching the production:
VersionNum::= '1.' [0-9]+

[1] https://www.w3.org/TR/REC-xml/#sec-prolog-dtd
@kornelski
Copy link
Owner

The conformance test you've removed was correct. 1.0 spec recommends against using any other version despite the grammar definition, and 1.1 allows only 1.1 and nothing else. There hasn't been any other XML version in the last 20 years.

https://www.w3.org/TR/xml11/#sec-prolog-dtd

Additionally, this is a semver-major break, which makes it a costly change.

@dbaron
Copy link

dbaron commented Nov 6, 2025

The relevant part of XML 1.0 separates requirements for processors and requirements for documents.

This text:

Even though the VersionNum production matches any version number of the form '1.x', XML 1.0 documents SHOULD NOT specify a version number other than '1.0'.

is a requirement for documents, not for processors.

The normative text for processors is the grammar (which requires accepting any 1.x version), plus the note:

When an XML 1.0 processor encounters a document that specifies a 1.x version number other than '1.0', it will process it as a 1.0 document. This means that an XML 1.0 processor will accept 1.x documents provided they do not use any non-1.0 features.

(This was a change in the Fifth Edition of XML 1.0, which was a revision whose goals were, I think, roughly, abandoning XML 1.1 and accomplishing its goals by changing XML 1.0.)

@drott
Copy link
Author

drott commented Nov 6, 2025

The conformance test you've removed was correct. 1.0 spec recommends against using any other version despite the grammar definition, and 1.1 allows only 1.1 and nothing else. There hasn't been any other XML version in the last 20 years.

I removed the failure expectation, not the test, right? The test is still running and is now passing because version 1.7 is now accepted, as the test expects. The tests description and expectation is: "a document with version=1.7, legal in XML 1.0 from 5th edition".

Additionally, this is a semver-major break, which makes it a costly change.

That's unfortunately true. And for fixing #55, for which I submitted #57, we would need another API modification - so my proposal would be to bundle these two changes before releasing a new major version.

@kornelski
Copy link
Owner

I'll make it parse, but for back-compat make it report as 1.0 (because that's the only version that allows >1.1)

@kornelski kornelski merged commit f41c145 into kornelski:main Nov 15, 2025
2 checks passed
aarongable pushed a commit to chromium/chromium that referenced this pull request Nov 20, 2025
Improved DOCTYPE parsing, string conversion for XMLVersion
and allowing documents with version 1.x.

Covers Googler pull requests 54, 56, 57:
kornelski/xml-rs#54
kornelski/xml-rs#56
kornelski/xml-rs#57

Changes merged in upstream but no version released yet.

Covers $ git log 1.1.0..
bd8fe07 Allow parsing of XML Version 1.x to improve conformance
18c4d62 Move assert_match macro
30227e8 Nicer comparison for OwnedName
f0e34b3 Thinner string type
aba9a85 Backwards-compatible DOCTYPE properties
7da7012 Provide name, public and system id in Doctype event
34458a2 Add `as_str()` method to `XmlVersion` `enum`.

Bug: 441911594
Change-Id: Icc58864e4393fe2725f9137f52cf92c23a5f3ba7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7172953
Auto-Submit: Dominik Röttsches <drott@chromium.org>
Reviewed-by: Łukasz Anforowicz <lukasza@chromium.org>
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1547919}
mohd-akram pushed a commit to gsource-mirror/chromium-src-third_party-rust that referenced this pull request Jan 9, 2026
Improved DOCTYPE parsing, string conversion for XMLVersion
and allowing documents with version 1.x.

Covers Googler pull requests 54, 56, 57:
kornelski/xml-rs#54
kornelski/xml-rs#56
kornelski/xml-rs#57

Changes merged in upstream but no version released yet.

Covers $ git log 1.1.0..
bd8fe07 Allow parsing of XML Version 1.x to improve conformance
18c4d62 Move assert_match macro
30227e8 Nicer comparison for OwnedName
f0e34b3 Thinner string type
aba9a85 Backwards-compatible DOCTYPE properties
7da7012 Provide name, public and system id in Doctype event
34458a2 Add `as_str()` method to `XmlVersion` `enum`.

Bug: 441911594
Change-Id: Icc58864e4393fe2725f9137f52cf92c23a5f3ba7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7172953
Auto-Submit: Dominik Röttsches <drott@chromium.org>
Reviewed-by: Łukasz Anforowicz <lukasza@chromium.org>
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1547919}
NOKEYCHECK=True
GitOrigin-RevId: e35fe768bc00fbe9e2c49e6f5334140eb8446b50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants