Skip to content

gh-57587: Add the namespaces parameter to the ElementTree serializer - #157523

Open
serhiy-storchaka wants to merge 3 commits into
python:mainfrom
serhiy-storchaka:gh-57587-serializer-namespaces
Open

serhiy-storchaka wants to merge 3 commits into
python:mainfrom
serhiy-storchaka:gh-57587-serializer-namespaces

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

tostring(), tostringlist() and ElementTree.write() accept a mapping from namespace prefixes to URIs which chooses the prefixes for this serialization, instead of the global registry of register_namespace(). Only the namespaces used in the tree are declared; the empty prefix sets the default namespace; a registered prefix which the mapping reserves for another namespace is not used.

Based on #157521, which adds the validation of prefixes.

…r_namespace()

ValueError is now raised for an invalid prefix, for the reserved xmlns
prefix, and for the xml prefix bound to other namespace or other prefix
bound to the XML namespace, as the documentation always promised.
Only the reserved nsN prefixes were rejected before.
…lizer

tostring(), tostringlist() and ElementTree.write() accept a mapping from
namespace prefixes to URIs which chooses the prefixes for this
serialization, instead of the global registry of register_namespace().
Only the namespaces used in the tree are declared; the empty prefix sets
the default namespace; a registered prefix which the mapping reserves for
another namespace is not used.
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34556215 | 📁 Comparing 0b69d6f against main (c215919)

  🔍 Preview build  

3 files changed
± library/xml.etree.elementtree.html
± whatsnew/3.16.html
± whatsnew/changelog.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant