1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """
18 The I{schema} module provides a intelligent representation of
19 an XSD schema. The I{raw} model is the XML tree and the I{model}
20 is the denormalized, objectified and intelligent view of the schema.
21 Most of the I{value-add} provided by the model is centered around
22 tranparent referenced type resolution and targeted denormalization.
23 """
24
25 from logging import getLogger
26 from suds import *
27 from suds.sax import Namespace, splitPrefix
28
29 log = getLogger(__name__)
30
31
33 """
34 Get a reference that is I{qualified} by namespace.
35 @param ref: A referenced schema type name.
36 @type ref: str
37 @param resolvers: A list of objects to be used to resolve types.
38 @type resolvers: [L{sax.element.Element},]
39 @param defns: An optional target namespace used to qualify references
40 when no prefix is specified.
41 @type defns: A default namespace I{tuple: (prefix,uri)} used when ref not prefixed.
42 @return: A qualified reference.
43 @rtype: (name, namespace-uri)
44 """
45 ns = None
46 p, n = splitPrefix(ref)
47 if p is not None:
48 if not isinstance(resolvers, (list, tuple)):
49 resolvers = (resolvers,)
50 for r in resolvers:
51 resolved = r.resolvePrefix(p)
52 if resolved[1] is not None:
53 ns = resolved
54 break
55 if ns is None:
56 raise Exception('prefix (%s) not resolved' % p)
57 else:
58 ns = defns
59 return (n, ns[1])
60
62 """
63 Get whether the object is a I{qualified reference}.
64 @param object: An object to be tested.
65 @type object: I{any}
66 @rtype: boolean
67 @see: L{qualify}
68 """
69 return (\
70 isinstance(object, tuple) and \
71 len(object) == 2 and \
72 isinstance(object[0], basestring) and \
73 isinstance(object[1], basestring))
74
75
77 - def __init__(self, inclusive=False, *items):
78 self.inclusive = inclusive
79 self.items = items
86