aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/xmltodict/patches/01-pr-290.patch
blob: de530c96edded6f5cc9d2eeb7dcbecf07dbfbfd3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
From b9f4e5f91e1821dbffe3db27c1dd6b6e76f4cbec Mon Sep 17 00:00:00 2001
From: Sebastian Pipping <sebastian@pipping.org>
Date: Sun, 27 Feb 2022 02:07:55 +0100
Subject: [PATCH] Switch namespace separator from colon to pipe

---
 README.md               | 12 ++++++------
 tests/test_dicttoxml.py | 10 +++++-----
 tests/test_xmltodict.py | 16 ++++++++--------
 xmltodict.py            | 10 +++++-----
 4 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/README.md b/README.md
index ab63401..9309837 100644
--- contrib/python/xmltodict/README.md
+++ contrib/python/xmltodict/README.md
@@ -48,10 +48,10 @@ By default, `xmltodict` does no XML namespace processing (it just treats namespa
 ... </root>
 ... """
 >>> xmltodict.parse(xml, process_namespaces=True) == {
-...     'http://defaultns.com/:root': {
-...         'http://defaultns.com/:x': '1',
-...         'http://a.com/:y': '2',
-...         'http://b.com/:z': '3',
+...     'http://defaultns.com/|root': {
+...         'http://defaultns.com/|x': '1',
+...         'http://a.com/|y': '2',
+...         'http://b.com/|z': '3',
 ...     }
 ... }
 True
@@ -67,8 +67,8 @@ It also lets you collapse certain namespaces to shorthand prefixes, or skip them
 >>> xmltodict.parse(xml, process_namespaces=True, namespaces=namespaces) == {
 ...     'root': {
 ...         'x': '1',
-...         'ns_a:y': '2',
-...         'http://b.com/:z': '3',
+...         'ns_a|y': '2',
+...         'http://b.com/|z': '3',
 ...     },
 ... }
 True
diff --git a/tests/test_dicttoxml.py b/tests/test_dicttoxml.py
index 7fc2171..dd74989 100644
--- contrib/python/xmltodict/tests/test_dicttoxml.py
+++ contrib/python/xmltodict/tests/test_dicttoxml.py
@@ -178,18 +178,18 @@ def test_short_empty_elements(self):
 
     def test_namespace_support(self):
         obj = OrderedDict((
-            ('http://defaultns.com/:root', OrderedDict((
+            ('http://defaultns.com/|root', OrderedDict((
                 ('@xmlns', OrderedDict((
                     ('', 'http://defaultns.com/'),
                     ('a', 'http://a.com/'),
                     ('b', 'http://b.com/'),
                 ))),
-                ('http://defaultns.com/:x', OrderedDict((
-                    ('@http://a.com/:attr', 'val'),
+                ('http://defaultns.com/|x', OrderedDict((
+                    ('@http://a.com/|attr', 'val'),
                     ('#text', '1'),
                 ))),
-                ('http://a.com/:y', '2'),
-                ('http://b.com/:z', '3'),
+                ('http://a.com/|y', '2'),
+                ('http://b.com/|z', '3'),
             ))),
         ))
         ns = {
diff --git a/tests/test_xmltodict.py b/tests/test_xmltodict.py
index 0455d96..762768a 100644
--- contrib/python/xmltodict/tests/test_xmltodict.py
+++ contrib/python/xmltodict/tests/test_xmltodict.py
@@ -190,18 +190,18 @@ def test_namespace_support(self):
         </root>
         """
         d = {
-            'http://defaultns.com/:root': {
-                'http://defaultns.com/:x': {
+            'http://defaultns.com/|root': {
+                'http://defaultns.com/|x': {
                     '@xmlns': {
                         '': 'http://defaultns.com/',
                         'a': 'http://a.com/',
                         'b': 'http://b.com/',
                     },
-                    '@http://a.com/:attr': 'val',
+                    '@http://a.com/|attr': 'val',
                     '#text': '1',
                 },
-                'http://a.com/:y': '2',
-                'http://b.com/:z': '3',
+                'http://a.com/|y': '2',
+                'http://b.com/|z': '3',
             }
         }
         res = parse(xml, process_namespaces=True)
@@ -229,11 +229,11 @@ def test_namespace_collapse(self):
                         'a': 'http://a.com/',
                         'b': 'http://b.com/',
                     },
-                    '@ns_a:attr': 'val',
+                    '@ns_a|attr': 'val',
                     '#text': '1',
                 },
-                'ns_a:y': '2',
-                'http://b.com/:z': '3',
+                'ns_a|y': '2',
+                'http://b.com/|z': '3',
             },
         }
         res = parse(xml, process_namespaces=True, namespaces=namespaces)
diff --git a/xmltodict.py b/xmltodict.py
index a070961..b7577e1 100755
--- contrib/python/xmltodict/xmltodict.py
+++ contrib/python/xmltodict/xmltodict.py
@@ -48,7 +48,7 @@ def __init__(self,
                  postprocessor=None,
                  dict_constructor=OrderedDict,
                  strip_whitespace=True,
-                 namespace_separator=':',
+                 namespace_separator='|',
                  namespaces=None,
                  force_list=None,
                  comment_key='#comment'):
@@ -196,7 +196,7 @@ def _should_force_list(self, key, value):
 
 
 def parse(xml_input, encoding=None, expat=expat, process_namespaces=False,
-          namespace_separator=':', disable_entities=True, **kwargs):
+          namespace_separator='|', disable_entities=True, **kwargs):
     """Parse the given XML input and convert it into a dictionary.
 
     `xml_input` can either be a `string`, a file-like object, or a generator of strings.
@@ -375,7 +375,7 @@ def parse(xml_input, encoding=None, expat=expat, process_namespaces=False,
     return handler.item
 
 
-def _process_namespace(name, namespaces, ns_sep=':', attr_prefix='@'):
+def _process_namespace(name, namespaces, ns_sep='|', attr_prefix='@'):
     if not namespaces:
         return name
     try:
@@ -386,7 +386,7 @@ def _process_namespace(name, namespaces, ns_sep=':', attr_prefix='@'):
         ns_res = namespaces.get(ns.strip(attr_prefix))
         name = '{}{}{}{}'.format(
             attr_prefix if ns.startswith(attr_prefix) else '',
-            ns_res, ns_sep, name) if ns_res else name
+            ns_res, ':', name) if ns_res else name
     return name
 
 
@@ -398,7 +398,7 @@ def _emit(key, value, content_handler,
           pretty=False,
           newl='\n',
           indent='\t',
-          namespace_separator=':',
+          namespace_separator='|',
           namespaces=None,
           full_document=True,
           expand_iter=None):