Skip to content

normalize namespace from minidom #44376

Closed

Description

@paulpach
mannequin
BPO 1621421
Nosy @devdanzin
Dependencies
  • bpo-1371937: minidom namespace problems
  • Files
  • normalizeNamespace.diff: normalizeNamespace.diff
  • test_toxml.py: test_toxml.py
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2006-12-23.20:01:44.000>
    labels = ['expert-XML', 'type-bug']
    title = 'normalize namespace from minidom'
    updated_at = <Date 2014-02-03.19:21:26.409>
    user = 'https://bugs.python.org/paulpach'

    bugs.python.org fields:

    activity = <Date 2014-02-03.19:21:26.409>
    actor = 'BreamoreBoy'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['XML']
    creation = <Date 2006-12-23.20:01:44.000>
    creator = 'paulpach'
    dependencies = ['1371937']
    files = ['7679', '7680']
    hgrepos = []
    issue_num = 1621421
    keywords = ['patch']
    message_count = 7.0
    messages = ['51605', '51606', '51607', '51608', '51609', '84599', '110515']
    nosy_count = 4.0
    nosy_names = ['jorend', 'ajaksu2', 'paulpach', 'admp']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue1621421'
    versions = ['Python 3.1', 'Python 2.7', 'Python 3.2']

    Linked PRs

    Activity

    1. paulpach commented on Dec 23, 2006

      paulpachmannequin
      MannequinAuthor

      This is a patch that fixes bug 1371937, along with a test case that reproduces the original problem.

      The patch is a port of the algorithm described here pretty much verbatim:
      http://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#normalizeDocumentAlgo

      to resolve namespace declarations. The patch also calls the normalizeNamespace method before calling writexml

      Note the patch is against minidom that comes with python 2.5, NOT WITH PYXML. I need this for an embedded project where pyxml is too big.

    2. paulpach commented on Dec 23, 2006

      paulpachmannequin
      MannequinAuthor

      File Added: normalizeNamespace.diff

    3. paulpach commented on Dec 24, 2006

      paulpachmannequin
      MannequinAuthor

      File Added: normalizeNamespace.diff

    4. paulpach commented on Dec 24, 2006

      paulpachmannequin
      MannequinAuthor

      File Added: test_toxml.py

    5. jorend commented on Mar 15, 2007

      jorendmannequin
      Mannequin

      Thanks for the patch.

      I think this is probably *not* desirable in this form. As a side effect of writexml(), this fixes up tagNames and attributes of elements in the document. DOM Level 3 Load and Save made the opposite decision: "The XML data is written to a string or an output stream. Any changes or fixups made during the serialization affect only the serialized data. The Document object and its children are never altered by the serialization operation." -- http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/load-save.html#LS-LSSerializer (first paragraph) I think that is the right approach.

      The new method Element.normalizeNamespace() isn't really a DOM method, though the appendix sort of makes it look that way.

      Incomplete - no doc patch. (I think there's also a bug in the line added to Document.writexml()-- can't Documents have children that aren't Elements?)

    6. devdanzin commented on Mar 30, 2009

      devdanzinmannequin
      Mannequin

      Patch has tests, fixes bpo-1371937.

    7. BreamoreBoy commented on Jul 16, 2010

      BreamoreBoymannequin
      Mannequin

      msg51609 doesn't seem too enthusiastic about the patch. msg84599 states unit tests are provided and bpo-1371937 is fixed. Can we have a definitive statement as to whether the patch is acceptable or not.

    8. transferred this issue fromon Apr 10, 2022
    9. added
      pendingThe issue will be closed if no feedback is provided
      on Sep 20, 2025
    10. devdanzin commented on Sep 20, 2025

      @devdanzin
      Member

      The tests don't run correctly, so they cannot be uses as-is to assess the fix. Given the 15 years without an update on this issue, I'm setting it to pending. If someone wants to update the tests and patch, we can keep it open until it's fixed.

    11. serhiy-storchaka commented on Sep 13, 2026

      @serhiy-storchaka
      Member

      #156674 fixes this in the way @jorend asked for in 2007: Element.writexml() writes the namespace declarations which are missing for the element and its attributes, without changing the document, as DOM Level 3 LS requires. It covers the cases of @paulpach's patch and test (an element and an attribute created with createElementNS()/setAttributeNS(), a prefix declared for an ancestor, the default namespace, an attribute in a namespace without a prefix), plus xmlns="" for an element in no namespace under a default namespace, and it reuses a prefix which is already bound to the namespace instead of inventing one.

      The normalizeNamespaces() algorithm of DOM Level 3 Core is not implemented, that is a separate feature.

    12. added 2 commits that reference this issue on Sep 13, 2026
    13. added a commit that references this issue on Sep 14, 2026
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      pendingThe issue will be closed if no feedback is providedtopic-XMLtype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions