Skip to content

Commit 528d03a

Browse files
committed
Don't use the target namespace for union / arraytype lookups
1 parent 7053006 commit 528d03a

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/zeep/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def qname_attr(node, attr_name, target_namespace=None):
1212
return as_qname(value, node.nsmap, target_namespace)
1313

1414

15-
def as_qname(value, nsmap, target_namespace):
15+
def as_qname(value, nsmap, target_namespace=None):
1616
"""Convert the given value to a QName"""
1717
if ':' in value:
1818
prefix, local = value.split(':')

src/zeep/xsd/visitor.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,7 @@ def visit_attribute(self, node, parent):
383383
match = re.match('([^\[]+)', array_type)
384384
if match:
385385
array_type = match.groups()[0]
386-
qname = as_qname(
387-
array_type, node.nsmap, self.document._target_namespace)
386+
qname = as_qname(array_type, node.nsmap)
388387
array_type = xsd_types.UnresolvedType(qname, self.schema)
389388

390389
# If the elment has a ref attribute then all other attributes cannot
@@ -987,7 +986,7 @@ def visit_union(self, node, parent):
987986
types = []
988987
if members:
989988
for member in members.split():
990-
qname = as_qname(member, node.nsmap, self.document._target_namespace)
989+
qname = as_qname(member, node.nsmap)
991990
xsd_type = self._get_type(qname)
992991
types.append(xsd_type)
993992
else:

tests/test_xsd_attributes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def test_attribute_union_type():
373373
<restriction base="xsd:string"/>
374374
</simpleType>
375375
<simpleType name="parent">
376-
<union memberTypes="one two"/>
376+
<union memberTypes="tns:one tns:two"/>
377377
</simpleType>
378378
<simpleType name="two">
379379
<restriction base="xsd:string"/>

tests/test_xsd_union.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ def test_union_same_types():
66
schema = xsd.Schema(load_xml("""
77
<?xml version="1.0"?>
88
<xsd:schema
9+
xmlns="http://tests.python-zeep.org/"
910
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
1011
xmlns:tns="http://tests.python-zeep.org/"
1112
targetNamespace="http://tests.python-zeep.org/"
@@ -21,7 +22,7 @@ def test_union_same_types():
2122
</xsd:simpleType>
2223
2324
<xsd:simpleType name="Date">
24-
<xsd:union memberTypes="MMYY MMYYYY"/>
25+
<xsd:union memberTypes="tns:MMYY MMYYYY"/>
2526
</xsd:simpleType>
2627
<xsd:element name="item" type="tns:Date"/>
2728
</xsd:schema>
@@ -49,7 +50,7 @@ def test_union_mixed():
4950
elementFormDefault="qualified">
5051
<xsd:element name="item" type="tns:Date"/>
5152
<xsd:simpleType name="Date">
52-
<xsd:union memberTypes="xsd:date xsd:gYear xsd:gYearMonth MMYY MMYYYY"/>
53+
<xsd:union memberTypes="xsd:date xsd:gYear xsd:gYearMonth tns:MMYY tns:MMYYYY"/>
5354
</xsd:simpleType>
5455
<xsd:simpleType name="MMYY">
5556
<xsd:restriction base="xsd:string">

0 commit comments

Comments
 (0)