suds.xsd package

Submodules

suds.xsd.depsort module

Dependency/topological sort implementation.

suds.xsd.depsort.dependency_sort(dependency_tree)

Sorts items ‘dependencies first’ in a given dependency tree.

A dependency tree is a dictionary mapping an object to a collection its dependency objects.

Result is a properly sorted list of items, where each item is a 2-tuple containing an object and its dependency list, as given in the input dependency tree.

If B is directly or indirectly dependent on A and they are not both a part of the same dependency cycle (i.e. then A is neither directly nor indirectly dependent on B) then A needs to come before B.

If A and B are a part of the same dependency cycle, i.e. if they are both directly or indirectly dependent on each other, then it does not matter which comes first.

Any entries found listed as dependencies, but that do not have their own dependencies listed as well, are logged & ignored.

Returns:The sorted items.
Return type:list

suds.xsd.doctor module

The doctor module provides classes for fixing broken (sick) schema(s).

class suds.xsd.doctor.Doctor

Schema Doctor.

examine(root)

Examine and repair the schema (if necessary). :param root: A schema root element. :type root: Element

class suds.xsd.doctor.Import(ns, location=None)

An <xs:import/> to be applied. :cvar xsdns: The XSD namespace. :type xsdns: (p,u) :ivar ns: An import namespace. :type ns: str :ivar location: An optional schemaLocation. :type location: str :ivar filter: A filter used to restrict application to

a particular schema.
add(root)

Add an <xs:import/> to the specified schema root. :param root: A schema root. :type root: Element

apply(root)

Apply the import (rule) to the specified schema. If the schema does not already contain an import for the namespace specified here, it is added. :param root: A schema root. :type root: Element

exists(root)

Check to see if the <xs:import/> already exists in the specified schema root by matching namespace. :param root: A schema root. :type root: Element

setfilter(filter)

Set the filter. :param filter: A filter to set. :type filter: TnsFilter

xsdns = ('xs', 'http://www.w3.org/2001/XMLSchema')
class suds.xsd.doctor.ImportDoctor(*imports)

Bases: suds.xsd.doctor.Doctor, suds.plugin.DocumentPlugin

Doctor used to fix missing imports. :ivar imports: A list of imports to apply. :type imports: [Import,…]

add(*imports)

Add a namespace to be checked. :param imports: A list of Import objects. :type imports: [Import,..]

examine(node)
parsed(context)
class suds.xsd.doctor.Practice

Bases: suds.xsd.doctor.Doctor

A collection of doctors. :ivar doctors: A list of doctors. :type doctors: list

add(doctor)

Add a doctor to the practice :param doctor: A doctor to add. :type doctor: Doctor

examine(root)
class suds.xsd.doctor.TnsFilter(*tns)

Target Namespace filter. :ivar tns: A list of target namespaces. :type tns: [str,…]

add(*tns)

Add targetNamespaces to be added. :param tns: A list of target namespaces. :type tns: [str,…]

match(root, ns)

Match by targetNamespace excluding those that are equal to the specified namespace to prevent adding an import to itself. :param root: A schema root. :type root: Element

suds.xsd.query module

The query module defines a class for performing schema queries.

class suds.xsd.query.AttrGroupQuery(ref=None)

Bases: suds.xsd.query.Query

Schema query class that searches for attributeGroup references in the specified schema.

execute(schema)

Execute this query using the specified schema. :param schema: The schema associated with the query. The schema is used

by the query to search for items.
Returns:The item matching the search criteria.
Return type:sxbase.SchemaObject
class suds.xsd.query.AttrQuery(ref=None)

Bases: suds.xsd.query.Query

Schema query class that searches for Attribute references in the specified schema. Matches on root Attribute by qname first, then searches deeper into the document.

execute(schema)

Execute this query using the specified schema. :param schema: The schema associated with the query. The schema is used

by the query to search for items.
Returns:The item matching the search criteria.
Return type:sxbase.SchemaObject
class suds.xsd.query.BlindQuery(ref=None)

Bases: suds.xsd.query.Query

Schema query class that blindly searches for a reference in the specified schema. It may be used to find Elements and Types but will match on an Element first. This query will also find builtins.

execute(schema)

Execute this query using the specified schema. :param schema: The schema associated with the query. The schema is used

by the query to search for items.
Returns:The item matching the search criteria.
Return type:sxbase.SchemaObject
class suds.xsd.query.ElementQuery(ref=None)

Bases: suds.xsd.query.Query

Schema query class that searches for Element references in the specified schema. Matches on root Elements by qname first, then searches deeper into the document.

execute(schema)

Execute this query using the specified schema. :param schema: The schema associated with the query. The schema is used

by the query to search for items.
Returns:The item matching the search criteria.
Return type:sxbase.SchemaObject
class suds.xsd.query.GroupQuery(ref=None)

Bases: suds.xsd.query.Query

Schema query class that searches for Group references in the specified schema.

execute(schema)

Execute this query using the specified schema. :param schema: The schema associated with the query. The schema is used

by the query to search for items.
Returns:The item matching the search criteria.
Return type:sxbase.SchemaObject
class suds.xsd.query.Query(ref=None)

Bases: suds.sudsobject.Object

Schema query base class.

execute(schema)

Execute this query using the specified schema. :param schema: The schema associated with the query. The schema is used

by the query to search for items.
Returns:The item matching the search criteria.
Return type:sxbase.SchemaObject
filter(result)

Filter the specified result based on query criteria. :param result: A potential result. :type result: sxbase.SchemaObject :return: True if result should be excluded. :rtype: boolean

result(result)

Query result post processing. :param result: A query result. :type result: sxbase.SchemaObject

class suds.xsd.query.TypeQuery(ref=None)

Bases: suds.xsd.query.Query

Schema query class that searches for Type references in the specified schema. Matches on root types only.

execute(schema)

Execute this query using the specified schema. :param schema: The schema associated with the query. The schema is used

by the query to search for items.
Returns:The item matching the search criteria.
Return type:sxbase.SchemaObject

suds.xsd.schema module

The schema module provides an intelligent representation of an XSD schema. The raw model is the XML tree and the model is a denormalized, objectified and intelligent view of the schema. Most of the value-add provided by the model is centered around transparent referenced type resolution and targeted denormalization.

class suds.xsd.schema.Schema(root, baseurl, options, loaded_schemata=None, container=None)

Bases: suds.UnicodeMixin

The schema is an objectification of a <schema/> (XSD) definition. It provides inspection, lookup and type resolution.

Variables:
  • root – The root node.
  • baseurl – The base URL for this schema.
  • container – A schema collection containing this schema.
  • children – A list of direct top level children.
  • all – A list of all (includes imported) top level children.
  • types – A schema types cache.
  • imports – A list of import objects.
  • elements – A list of <element/> objects.
  • attributes – A list of <attribute/> objects.
  • groups – A list of group objects.
  • agrps – A list of attribute group objects.
  • form_qualified – The flag indicating: (@elementFormDefault).
Tag = 'schema'
build()
Build the schema (object graph) using the root node using the factory.
  • Build the graph.
  • Collate the children.
builtin(ref, context=None)

Get whether the specified reference is an (xs) builtin.

Parameters:ref ((str|qref)) – A str or qref.
Returns:True if builtin, else False.
Return type:bool
custom(ref, context=None)

Get whether the specified reference is B{not} an (xs) builtin.

Parameters:ref ((str|qref)) – A str or qref.
Returns:True if B{not} a builtin, else False.
Return type:bool
dereference()

Instruct all children to perform dereferencing.

instance(root, baseurl, loaded_schemata, options)

Create and return an new schema object using the specified root and URL.

Parameters:
  • root (sax.element.Element) – A schema root node.
  • baseurl (str) – A base URL.
  • loaded_schemata (dict) – Already loaded schemata cache (URL –> Schema).
  • options (options.Options) – An options dictionary.
Returns:

The newly created schema object.

Return type:

Schema

@note: This is only used by Import children.

locate(ns)

Find a schema by namespace. Only the URI portion of the namespace is compared to each schema’s targetNamespace. The request is passed on to the container.

Parameters:ns ((prefix, URI)) – A namespace.
Returns:The schema matching the namespace, else None.
Return type:Schema
merge(schema)

Merge the schema contents.

Only objects not already contained in this schema’s collections are merged. This provides support for bidirectional imports producing cyclic includes.

Returns:self
Return type:Schema
mktns()

Make the schema’s target namespace.

Returns:namespace representation of the schema’s targetNamespace value.
Return type:(prefix, URI)
open_imports(options, loaded_schemata)

Instruct all contained sxbasic.Import children to import all of their referenced schemas. The imported schema contents are merged in.

Parameters:
  • options (options.Options) – An options dictionary.
  • loaded_schemata (dict) – Already loaded schemata cache (URL –> Schema).
str(indent=0)
class suds.xsd.schema.SchemaCollection(wsdl)

Bases: suds.UnicodeMixin

A collection of schema objects.

This class is needed because a WSDL may contain more then one <schema/> node.

Variables:
  • wsdl – A WSDL object.
  • children – A list contained schemas.
  • namespaces – A dictionary of contained schemas by namespace.
add(schema)

Add a schema node to the collection. Schema(s) within the same target namespace are consolidated.

Parameters:schema ((Schema)) – A schema object.
autoblend()

Ensure that all schemas within the collection import each other which has a blending effect.

Returns:self
Return type:SchemaCollection
load(options, loaded_schemata)
Load schema objects for the root nodes.
  • de-reference schemas
  • merge schemas
Parameters:
  • options (options.Options) – An options dictionary.
  • loaded_schemata (dict) – Already loaded schemata cache (URL –> Schema).
Returns:

The merged schema.

Return type:

Schema

locate(ns)

Find a schema by namespace. Only the URI portion of the namespace is compared to each schema’s targetNamespace.

Parameters:ns ((prefix, URI)) – A namespace.
Returns:The schema matching the namespace, else None.
Return type:Schema
merge()

Merge contained schemas into one.

Returns:The merged schema.
Return type:Schema

suds.xsd.sxbase module

Base classes representing XSD schema objects.

class suds.xsd.sxbase.Content(schema, root)

Bases: suds.xsd.sxbase.SchemaObject

XSD schema objects representing real XML document content.

class suds.xsd.sxbase.Iter(sx)

The content iterator - used to iterate the Content children.

The iterator provides a view of the children that is free of container elements such as <xsd::all/>, <xsd:choice/> or <xsd:sequence/>.

Variables:stack – A stack used to control nesting.
class Frame(sx)

A content iterator frame.

next()

Get the next item in the frame’s collection.

Returns:The next item or None
Return type:SchemaObject
next()

Get the next item.

Returns:A tuple: the next (child, ancestry).
Return type:(SchemaObject, [SchemaObject,..])

@raise StopIteration: A the end.

pop()

Pop the top frame.

Returns:The popped frame.
Return type:Frame

@raise StopIteration: when stack is empty.

push(sx)

Create a frame and push the specified object.

Parameters:sx (SchemaObject) – A schema object to push.
top()

Get the top frame.

Returns:The top frame.
Return type:Frame

@raise StopIteration: when stack is empty.

class suds.xsd.sxbase.NodeFinder(matcher, limit=0)

Find nodes based on flexable criteria.

matcher may be any object implementing a match(n) method.

Variables:
  • matcher – An object used as criteria for match.
  • limit – Limit the number of matches. 0=unlimited.
find(node, list)

Traverse the tree looking for matches.

Parameters:
  • node (SchemaObject) – A node to match on.
  • list (list) – A list to fill.
class suds.xsd.sxbase.SchemaObject(schema, root)

Bases: suds.UnicodeMixin

A schema object is an extension to object with schema awareness.

Variables:
  • root – The XML root element.
  • schema – The schema containing this object.
  • form_qualified – A flag indicating that @elementFormDefault has a value of qualified.
  • nillable – A flag indicating that @nillable has a value of true.
  • default – The default value.
  • rawchildren – A list raw of all children.
all()

Get whether this is an <xsd:all/>.

Returns:True if <xsd:all/>, else False.
Return type:boolean
any()

Get whether this is an <xsd:any/>.

Returns:True if <xsd:any/>, else False.
Return type:boolean
classmethod append(d, s, filter=<suds.xsd.Filter instance>)

Append B{s}ource XSD schema objects to the B{d}estination list.

B{filter} is used to decide which objects to append and which to skip.

Parameters:
  • d (list) – The destination list.
  • s (list) – The source list.
  • filter (Filter) – A filter that allows items to be appended.
attributes(filter=<suds.xsd.Filter instance>)

Get only the attribute content.

Parameters:filter (Filter) – A filter to constrain the result.
Returns:A list of (attr, ancestry) tuples.
Return type:[(SchemaObject, [SchemaObject,..]),..]
autoqualified()

The list of auto qualified attribute values.

Qualification means to convert values into qref.

Returns:A list of attribute names.
Return type:list
builtin()

Get whether this is a built-in schema-instance XSD type.

Returns:True if a built-in type, else False.
Return type:boolean
children(filter=<suds.xsd.Filter instance>)

Get only the direct or non-attribute content.

Parameters:filter (Filter) – A filter to constrain the result.
Returns:A list tuples: (child, ancestry)
Return type:[(SchemaObject, [SchemaObject,..]),..]
childtags()

Get a list of valid child tag names.

Returns:A list of child tag names.
Return type:[str,..]
choice()

Get whether this is an <xsd:choice/>.

Returns:True if <xsd:choice/>, else False.
Return type:boolean
content(collection=None, filter=<suds.xsd.Filter instance>, history=None)

Get a flattened list of this node’s contents.

Parameters:
  • collection (list) – A list to fill.
  • filter (Filter) – A filter used to constrain the result.
  • history (list) – The history list used to prevent cyclic dependency.
Returns:

The filled list.

Return type:

list

default_namespace()
dependencies()

Get a list of dependencies for dereferencing.

Returns:A merge dependency index and a list of dependencies.
Return type:(int, [SchemaObject,…])
description()

Get the names used for repr() and str() description.

Returns:A dictionary of relevant attributes.
Return type:[str,..]
enum()

Get whether this is a simple-type containing an enumeration.

Returns:True if enumeration, else False.
Return type:boolean
extension()

Get whether the object is an extension of another type.

Returns:True if an extension, else False.
Return type:boolean
find(qref, classes=[], ignore=None)

Find a referenced type in self or children. Return None if not found.

Qualified references for all schema objects checked in this search will be added to the set of ignored qualified references to avoid the find operation going into an infinite loop in case of recursively defined structures.

Parameters:
  • qref (qref) – A qualified reference.
  • classes (Collection(class,…), e.g. [I(class),…]) – A collection of classes used to qualify the match.
  • ignore ({qref,..}) – A set of qualified references to ignore in this search.
Returns:

The referenced type.

Return type:

SchemaObject

@see: qualify()

get_attribute(name)

Get (find) an attribute by name.

Parameters:name (str) – A attribute name.
Returns:A tuple: the requested (attribute, ancestry).
Return type:(SchemaObject, [SchemaObject,..])
get_child(name)

Get (find) a non-attribute child by name.

Parameters:name (str) – A child name.
Returns:A tuple: the requested (child, ancestry).
Return type:(SchemaObject, [SchemaObject,..])
isattr()

Get whether the object is a schema attribute definition.

Returns:True if an attribute, else False.
Return type:boolean
merge(other)

Merge another object as needed.

mixed()

Get whether the object has mixed content.

multi_occurrence()

Get whether the node has multiple occurrences, i.e. is a collection.

Returns:True if it has, False if it has at most 1 occurrence.
Return type:boolean
namespace(prefix=None)

Get this property’s namespace.

Parameters:prefix (str) – The default prefix.
Returns:The schema’s target namespace.
Return type:(prefix, URI)
optional()

Get whether this type is optional.

Returns:True if optional, else False.
Return type:boolean
classmethod prepend(d, s, filter=<suds.xsd.Filter instance>)

Prepend B{s}ource XSD schema objects to the B{d}estination list.

B{filter} is used to decide which objects to prepend and which to skip.

Parameters:
  • d (list) – The destination list.
  • s (list) – The source list.
  • filter (Filter) – A filter allowing items to be prepended.
qualify()

Convert reference attribute values into a qref.

Constructed qref uses the default document namespace. Since many WSDL schemas are written improperly: when the document does not define its default namespace, the schema target namespace is used to qualify references.

required()

Get whether this type is required.

Returns:True if required, else False.
Return type:boolean
resolve(nobuiltin=False)

Resolve the node’s type reference and return the referenced type node.

Only XSD schema objects that actually support ‘having a type’ custom implement this interface while others simply resolve as themselves.

Parameters:nobuiltin – Flag indicating whether resolving to an external XSD built-in type should not be allowed.
Returns:The resolved (true) type.
Return type:SchemaObject
restriction()

Get whether the object is an restriction of another type.

Returns:True if a restriction, else False.
Return type:boolean
sequence()

Get whether this is an <xsd:sequence/>.

Returns:True if <xsd:sequence/>, else False.
Return type:boolean
str(indent=0, history=None)

Get a string representation of this object.

Parameters:indent (int) – The indent.
Returns:A string.
Return type:str
translate(value, topython=True)

Translate between an XSD type values and Python objects.

When converting a Python object to an XSD type value the operation may return any Python object whose string representation matches the desired XSD type value.

Parameters:
  • value (str if topython is True; any Python object otherwise) – A value to translate.
  • topython (bool) – Flag indicating the translation direction.
Returns:

The converted language type.

xslist()

Get whether this is an <xsd:list/>.

Returns:True if <xsd:list/>, else False.
Return type:boolean
class suds.xsd.sxbase.XBuiltin(schema, name)

Bases: suds.xsd.sxbase.SchemaObject

Represents a built-in XSD schema <xsd:*/> node.

builtin()

Get whether this is a built-in schema-instance XSD type.

Returns:True if a built-in type, else False.
Return type:boolean
namespace(prefix=None)

Get this property’s namespace.

Parameters:prefix (str) – The default prefix.
Returns:The schema’s target namespace.
Return type:(prefix, URI)

suds.xsd.sxbasic module

Classes representing basic XSD schema objects.

class suds.xsd.sxbasic.All(schema, root)

Bases: suds.xsd.sxbasic.Collection

Represents an XSD schema <xsd:all/> node.

all()

Get whether this is an <xsd:all/>.

Returns:True if <xsd:all/>, else False.
Return type:boolean
class suds.xsd.sxbasic.Any(schema, root)

Bases: suds.xsd.sxbase.Content

Represents an XSD schema <any/> node.

any()

Get whether this is an <xsd:any/>.

Returns:True if <xsd:any/>, else False.
Return type:boolean
get_attribute(name)

Get (find) an attribute by name.

Parameters:name (str) – A attribute name.
Returns:A tuple: the requested (attribute, ancestry).
Return type:(SchemaObject, [SchemaObject,..])
get_child(name)

Get (find) a non-attribute child by name.

Parameters:name (str) – A child name.
Returns:A tuple: the requested (child, ancestry).
Return type:(SchemaObject, [SchemaObject,..])
class suds.xsd.sxbasic.Attribute(schema, root)

Bases: suds.xsd.sxbasic.TypedContent

Represents an XSD schema <attribute/> node.

childtags()

Get a list of valid child tag names.

Returns:A list of child tag names.
Return type:[str,..]
dependencies()

Get a list of dependencies for dereferencing.

Returns:A merge dependency index and a list of dependencies.
Return type:(int, [SchemaObject,…])
description()

Get the names used for repr() and str() description.

Returns:A dictionary of relevant attributes.
Return type:[str,..]
get_default()

Gets the <xsd:attribute default=””/> attribute value.

Returns:The default value for the attribute
Return type:str
isattr()

Get whether the object is a schema attribute definition.

Returns:True if an attribute, else False.
Return type:boolean
optional()

Get whether this type is optional.

Returns:True if optional, else False.
Return type:boolean
class suds.xsd.sxbasic.AttributeGroup(schema, root)

Bases: suds.xsd.sxbase.SchemaObject

Represents an XSD schema <xsd:attributeGroup/> node.

Variables:childtags – A list of valid child node names.
childtags()

Get a list of valid child tag names.

Returns:A list of child tag names.
Return type:[str,..]
dependencies()

Get a list of dependencies for dereferencing.

Returns:A merge dependency index and a list of dependencies.
Return type:(int, [SchemaObject,…])
description()

Get the names used for repr() and str() description.

Returns:A dictionary of relevant attributes.
Return type:[str,..]
merge(other)

Merge another object as needed.

class suds.xsd.sxbasic.Choice(schema, root)

Bases: suds.xsd.sxbasic.Collection

Represents an XSD schema <xsd:choice/> node.

choice()

Get whether this is an <xsd:choice/>.

Returns:True if <xsd:choice/>, else False.
Return type:boolean
class suds.xsd.sxbasic.Collection(schema, root)

Bases: suds.xsd.sxbase.SchemaObject

Represents an XSD schema collection (a.k.a. order indicator) node.

childtags()

Get a list of valid child tag names.

Returns:A list of child tag names.
Return type:[str,..]
class suds.xsd.sxbasic.Complex(schema, root)

Bases: suds.xsd.sxbase.SchemaObject

Represents an XSD schema <xsd:complexType/> node.

Variables:childtags – A list of valid child node names.
childtags()

Get a list of valid child tag names.

Returns:A list of child tag names.
Return type:[str,..]
description()

Get the names used for repr() and str() description.

Returns:A dictionary of relevant attributes.
Return type:[str,..]
extension()

Get whether the object is an extension of another type.

Returns:True if an extension, else False.
Return type:boolean
mixed()

Get whether the object has mixed content.

class suds.xsd.sxbasic.ComplexContent(schema, root)

Bases: suds.xsd.sxbase.SchemaObject

Represents an XSD schema <xsd:complexContent/> node.

childtags()

Get a list of valid child tag names.

Returns:A list of child tag names.
Return type:[str,..]
extension()

Get whether the object is an extension of another type.

Returns:True if an extension, else False.
Return type:boolean
restriction()

Get whether the object is an restriction of another type.

Returns:True if a restriction, else False.
Return type:boolean
class suds.xsd.sxbasic.Element(schema, root)

Bases: suds.xsd.sxbasic.TypedContent

Represents an XSD schema <xsd:element/> node.

anytype()

Create an xsd:anyType reference.

childtags()

Get a list of valid child tag names.

Returns:A list of child tag names.
Return type:[str,..]
dependencies()

Get a list of dependencies for dereferencing.

Returns:A merge dependency index and a list of dependencies.
Return type:(int, [SchemaObject,…])
description()

Get the names used for repr() and str() description.

Returns:A dictionary of relevant attributes.
Return type:[str,..]
extension()

Get whether the object is an extension of another type.

Returns:True if an extension, else False.
Return type:boolean
implany()

Set the type to <xsd:any/> when implicit.

An element has an implicit <xsd:any/> type when it has no body and no explicitly defined type.

Returns:self
Return type:Element
merge(other)

Merge another object as needed.

namespace(prefix=None)

Get this schema element’s target namespace.

In case of reference elements, the target namespace is defined by the referenced and not the referencing element node.

Parameters:prefix (str) – The default prefix.
Returns:The schema element’s target namespace
Return type:(prefix,``URI``)
restriction()

Get whether the object is an restriction of another type.

Returns:True if a restriction, else False.
Return type:boolean
class suds.xsd.sxbasic.Enumeration(schema, root)

Bases: suds.xsd.sxbase.Content

Represents an XSD schema <xsd:enumeration/> node.

description()

Get the names used for repr() and str() description.

Returns:A dictionary of relevant attributes.
Return type:[str,..]
enum()

Get whether this is a simple-type containing an enumeration.

Returns:True if enumeration, else False.
Return type:boolean
class suds.xsd.sxbasic.Extension(schema, root)

Bases: suds.xsd.sxbase.SchemaObject

Represents an XSD schema <xsd:extension/> node.

childtags()

Get a list of valid child tag names.

Returns:A list of child tag names.
Return type:[str,..]
dependencies()

Get a list of dependencies for dereferencing.

Returns:A merge dependency index and a list of dependencies.
Return type:(int, [SchemaObject,…])
description()

Get the names used for repr() and str() description.

Returns:A dictionary of relevant attributes.
Return type:[str,..]
extension()

Get whether the object is an extension of another type.

Returns:True if an extension, else False.
Return type:boolean
merge(other)

Merge another object as needed.

class suds.xsd.sxbasic.Factory
Variables:tags – A factory to create object objects based on tag.
classmethod build(root, schema, filter=('*', ))

Build an xsobject representation.

Parameters:
  • root (sax.element.Element) – An schema XML root.
  • filter ([str,..]) – A tag filter.
Returns:

A schema object graph.

Return type:

sxbase.SchemaObject

classmethod collate(children)
classmethod create(root, schema)

Create an object based on the root tag name.

Parameters:
  • root (Element) – An XML root element.
  • schema (schema.Schema) – A schema object.
Returns:

The created object.

Return type:

SchemaObject

classmethod maptag(tag, fn)

Map (override) tag => class mapping.

Parameters:
  • tag (str) – An XSD tag name.
  • fn (fn|class.) – A function or class.
tags = {'all': <class 'suds.xsd.sxbasic.All'>, 'any': <class 'suds.xsd.sxbasic.Any'>, 'attribute': <function __fn>, 'attributeGroup': <class 'suds.xsd.sxbasic.AttributeGroup'>, 'choice': <class 'suds.xsd.sxbasic.Choice'>, 'complexContent': <class 'suds.xsd.sxbasic.ComplexContent'>, 'complexType': <class 'suds.xsd.sxbasic.Complex'>, 'element': <class 'suds.xsd.sxbasic.Element'>, 'enumeration': <class 'suds.xsd.sxbasic.Enumeration'>, 'extension': <class 'suds.xsd.sxbasic.Extension'>, 'group': <class 'suds.xsd.sxbasic.Group'>, 'import': <class 'suds.xsd.sxbasic.Import'>, 'include': <class 'suds.xsd.sxbasic.Include'>, 'list': <class 'suds.xsd.sxbasic.List'>, 'restriction': <class 'suds.xsd.sxbasic.Restriction'>, 'sequence': <class 'suds.xsd.sxbasic.Sequence'>, 'simpleContent': <class 'suds.xsd.sxbasic.SimpleContent'>, 'simpleType': <class 'suds.xsd.sxbasic.Simple'>}
class suds.xsd.sxbasic.Group(schema, root)

Bases: suds.xsd.sxbase.SchemaObject

Represents an XSD schema <xsd:group/> node.

Variables:childtags – A list of valid child node names.
childtags()

Get a list of valid child tag names.

Returns:A list of child tag names.
Return type:[str,..]
dependencies()

Get a list of dependencies for dereferencing.

Returns:A merge dependency index and a list of dependencies.
Return type:(int, [SchemaObject,…])
description()

Get the names used for repr() and str() description.

Returns:A dictionary of relevant attributes.
Return type:[str,..]
merge(other)

Merge another object as needed.

class suds.xsd.sxbasic.Import(schema, root)

Bases: suds.xsd.sxbase.SchemaObject

Represents an XSD schema <xsd:import/> node.

Variables:
  • locations – A dictionary of namespace locations.
  • ns – The imported namespace.
  • location – The (optional) location.
  • opened – Opened and imported flag.
classmethod bind(ns, location=None)

Bind a namespace to a schema location (URI).

This is used for imports that do not specify a schemaLocation.

Parameters:
  • ns (str) – A namespace-uri.
  • location (str) – The (optional) schema location for the namespace. (default=ns)
description()

Get the names used for repr() and str() description.

Returns:A dictionary of relevant attributes.
Return type:[str,..]
locations = {'http://schemas.xmlsoap.org/soap/encoding/': 'suds://schemas.xmlsoap.org/soap/encoding/', 'http://www.w3.org/2001/XMLSchema': 'http://www.w3.org/2001/XMLSchema.xsd', 'http://www.w3.org/XML/1998/namespace': 'http://www.w3.org/2001/xml.xsd'}
open(options, loaded_schemata)

Open and import the referenced schema.

Parameters:
  • options (options.Options) – An options dictionary.
  • loaded_schemata (dict) – Already loaded schemata cache (URL –> Schema).
Returns:

The referenced schema.

Return type:

Schema

class suds.xsd.sxbasic.Include(schema, root)

Bases: suds.xsd.sxbase.SchemaObject

Represents an XSD schema <xsd:include/> node.

Variables:
  • location – The (optional) location.
  • opened – Opened and imported flag.
description()

Get the names used for repr() and str() description.

Returns:A dictionary of relevant attributes.
Return type:[str,..]
locations = {}
open(options, loaded_schemata)

Open and include the referenced schema.

Parameters:
  • options (options.Options) – An options dictionary.
  • loaded_schemata (dict) – Already loaded schemata cache (URL –> Schema).
Returns:

The referenced schema.

Return type:

Schema

class suds.xsd.sxbasic.List(schema, root)

Bases: suds.xsd.sxbase.SchemaObject

Represents an XSD schema <xsd:list/> node.

childtags()

Get a list of valid child tag names.

Returns:A list of child tag names.
Return type:[str,..]
description()

Get the names used for repr() and str() description.

Returns:A dictionary of relevant attributes.
Return type:[str,..]
xslist()

Get whether this is an <xsd:list/>.

Returns:True if <xsd:list/>, else False.
Return type:boolean
class suds.xsd.sxbasic.Restriction(schema, root)

Bases: suds.xsd.sxbase.SchemaObject

Represents an XSD schema <xsd:restriction/> node.

childtags()

Get a list of valid child tag names.

Returns:A list of child tag names.
Return type:[str,..]
dependencies()

Get a list of dependencies for dereferencing.

Returns:A merge dependency index and a list of dependencies.
Return type:(int, [SchemaObject,…])
description()

Get the names used for repr() and str() description.

Returns:A dictionary of relevant attributes.
Return type:[str,..]
merge(other)

Merge another object as needed.

restriction()

Get whether the object is an restriction of another type.

Returns:True if a restriction, else False.
Return type:boolean
class suds.xsd.sxbasic.RestrictionMatcher

For use with NodeFinder to match restriction.

match(n)
class suds.xsd.sxbasic.Sequence(schema, root)

Bases: suds.xsd.sxbasic.Collection

Represents an XSD schema <xsd:sequence/> node.

sequence()

Get whether this is an <xsd:sequence/>.

Returns:True if <xsd:sequence/>, else False.
Return type:boolean
class suds.xsd.sxbasic.Simple(schema, root)

Bases: suds.xsd.sxbase.SchemaObject

Represents an XSD schema <xsd:simpleType/> node.

childtags()

Get a list of valid child tag names.

Returns:A list of child tag names.
Return type:[str,..]
description()

Get the names used for repr() and str() description.

Returns:A dictionary of relevant attributes.
Return type:[str,..]
enum()

Get whether this is a simple-type containing an enumeration.

Returns:True if enumeration, else False.
Return type:boolean
extension()

Get whether the object is an extension of another type.

Returns:True if an extension, else False.
Return type:boolean
mixed()

Get whether the object has mixed content.

restriction()

Get whether the object is an restriction of another type.

Returns:True if a restriction, else False.
Return type:boolean
class suds.xsd.sxbasic.SimpleContent(schema, root)

Bases: suds.xsd.sxbase.SchemaObject

Represents an XSD schema <xsd:simpleContent/> node.

childtags()

Get a list of valid child tag names.

Returns:A list of child tag names.
Return type:[str,..]
extension()

Get whether the object is an extension of another type.

Returns:True if an extension, else False.
Return type:boolean
mixed()

Get whether the object has mixed content.

restriction()

Get whether the object is an restriction of another type.

Returns:True if a restriction, else False.
Return type:boolean
class suds.xsd.sxbasic.TypedContent(*args, **kwargs)

Bases: suds.xsd.sxbase.Content

Represents any typed content.

qref()

Get the type qualified reference to the referenced XSD type.

This method takes into account simple types defined through restriction which are detected by determining that self is simple (len == 0) and by finding a restriction child.

Returns:The type qualified reference.
Return type:qref
resolve(nobuiltin=False)

Resolve the node’s type reference and return the referenced type node.

Returns self if the type is defined locally, e.g. as a <complexType> subnode. Otherwise returns the referenced external node.

Parameters:nobuiltin – Flag indicating whether resolving to XSD built-in types should not be allowed.
Returns:The resolved (true) type.
Return type:SchemaObject

suds.xsd.sxbuiltin module

Classes representing built-in XSD schema objects.

class suds.xsd.sxbuiltin.Factory
classmethod create(schema, name)

Create an object based on the root tag name.

Parameters:
  • schema (schema.Schema) – A schema object.
  • name (str) – The name.
Returns:

The created object.

Return type:

XBuiltin

classmethod maptag(tag, fn)

Map (override) tag => class mapping.

Parameters:
  • tag (str) – An XSD tag name.
  • fn (fn|class.) – A function or class.
tags = {'ENTITIES': <class 'suds.xsd.sxbuiltin.XString'>, 'ENTITY': <class 'suds.xsd.sxbuiltin.XString'>, 'ID': <class 'suds.xsd.sxbuiltin.XString'>, 'IDREF': <class 'suds.xsd.sxbuiltin.XString'>, 'IDREFS': <class 'suds.xsd.sxbuiltin.XString'>, 'NCName': <class 'suds.xsd.sxbuiltin.XString'>, 'NMTOKEN': <class 'suds.xsd.sxbuiltin.XString'>, 'NMTOKENS': <class 'suds.xsd.sxbuiltin.XString'>, 'NOTATION': <class 'suds.xsd.sxbuiltin.XString'>, 'Name': <class 'suds.xsd.sxbuiltin.XString'>, 'QName': <class 'suds.xsd.sxbuiltin.XString'>, 'anySimpleType': <class 'suds.xsd.sxbuiltin.XString'>, 'anyType': <class 'suds.xsd.sxbuiltin.XAny'>, 'anyURI': <class 'suds.xsd.sxbuiltin.XString'>, 'base64Binary': <class 'suds.xsd.sxbuiltin.XString'>, 'boolean': <class 'suds.xsd.sxbuiltin.XBoolean'>, 'byte': <class 'suds.xsd.sxbuiltin.XInteger'>, 'date': <class 'suds.xsd.sxbuiltin.XDate'>, 'dateTime': <class 'suds.xsd.sxbuiltin.XDateTime'>, 'decimal': <class 'suds.xsd.sxbuiltin.XDecimal'>, 'double': <class 'suds.xsd.sxbuiltin.XFloat'>, 'duration': <class 'suds.xsd.sxbuiltin.XString'>, 'float': <class 'suds.xsd.sxbuiltin.XFloat'>, 'gDay': <class 'suds.xsd.sxbuiltin.XString'>, 'gMonth': <class 'suds.xsd.sxbuiltin.XString'>, 'gMonthDay': <class 'suds.xsd.sxbuiltin.XString'>, 'gYear': <class 'suds.xsd.sxbuiltin.XString'>, 'gYearMonth': <class 'suds.xsd.sxbuiltin.XString'>, 'hexBinary': <class 'suds.xsd.sxbuiltin.XString'>, 'int': <class 'suds.xsd.sxbuiltin.XInteger'>, 'integer': <class 'suds.xsd.sxbuiltin.XInteger'>, 'language': <class 'suds.xsd.sxbuiltin.XString'>, 'long': <class 'suds.xsd.sxbuiltin.XLong'>, 'negativeInteger': <class 'suds.xsd.sxbuiltin.XInteger'>, 'nonNegativeInteger': <class 'suds.xsd.sxbuiltin.XInteger'>, 'nonPositiveInteger': <class 'suds.xsd.sxbuiltin.XInteger'>, 'normalizedString': <class 'suds.xsd.sxbuiltin.XString'>, 'positiveInteger': <class 'suds.xsd.sxbuiltin.XInteger'>, 'short': <class 'suds.xsd.sxbuiltin.XInteger'>, 'string': <class 'suds.xsd.sxbuiltin.XString'>, 'time': <class 'suds.xsd.sxbuiltin.XTime'>, 'token': <class 'suds.xsd.sxbuiltin.XString'>, 'unsignedByte': <class 'suds.xsd.sxbuiltin.XInteger'>, 'unsignedInt': <class 'suds.xsd.sxbuiltin.XInteger'>, 'unsignedLong': <class 'suds.xsd.sxbuiltin.XLong'>, 'unsignedShort': <class 'suds.xsd.sxbuiltin.XInteger'>}
class suds.xsd.sxbuiltin.XAny(schema, name)

Bases: suds.xsd.sxbase.XBuiltin

Represents an XSD <xsd:any/> node.

any()

Get whether this is an <xsd:any/>.

Returns:True if <xsd:any/>, else False.
Return type:boolean
get_child(name)

Get (find) a non-attribute child by name.

Parameters:name (str) – A child name.
Returns:A tuple: the requested (child, ancestry).
Return type:(SchemaObject, [SchemaObject,..])
class suds.xsd.sxbuiltin.XBoolean(schema, name)

Bases: suds.xsd.sxbase.XBuiltin

Represents an XSD boolean built-in type.

static translate(value, topython=True)
class suds.xsd.sxbuiltin.XDate(schema, name)

Bases: suds.xsd.sxbase.XBuiltin

Represents an XSD <xsd:date/> built-in type.

static translate(value, topython=True)
class suds.xsd.sxbuiltin.XDateTime(schema, name)

Bases: suds.xsd.sxbase.XBuiltin

Represents an XSD <xsd:datetime/> built-in type.

static translate(value, topython=True)
class suds.xsd.sxbuiltin.XDecimal(schema, name)

Bases: suds.xsd.sxbase.XBuiltin

Represents an XSD <xsd:decimal/> built-in type.

Excerpt from the XSD datatype specification (http://www.w3.org/TR/2004/REC-xmlschema-2-20041028):

> 3.2.3 decimal > > [Definition:] decimal represents a subset of the real numbers, which can > be represented by decimal numerals. The ·value space· of decimal is the > set of numbers that can be obtained by multiplying an integer by a > non-positive power of ten, i.e., expressible as i × 10^-n where i and n > are integers and n >= 0. Precision is not reflected in this value space; > the number 2.0 is not distinct from the number 2.00. The ·order-relation· > on decimal is the order relation on real numbers, restricted to this > subset. > > 3.2.3.1 Lexical representation > > decimal has a lexical representation consisting of a finite-length > sequence of decimal digits (#x30-#x39) separated by a period as a decimal > indicator. An optional leading sign is allowed. If the sign is omitted, > “+” is assumed. Leading and trailing zeroes are optional. If the > fractional part is zero, the period and following zero(es) can be > omitted. For example: -1.23, 12678967.543233, +100000.00, 210.

classmethod translate(value, topython=True)

Translate between an XSD type values and Python objects.

When converting a Python object to an XSD type value the operation may return any Python object whose string representation matches the desired XSD type value.

Parameters:
  • value (str if topython is True; any Python object otherwise) – A value to translate.
  • topython (bool) – Flag indicating the translation direction.
Returns:

The converted language type.

class suds.xsd.sxbuiltin.XFloat(schema, name)

Bases: suds.xsd.sxbase.XBuiltin

Represents an XSD <xsd:float/> built-in type.

static translate(value, topython=True)
class suds.xsd.sxbuiltin.XInteger(schema, name)

Bases: suds.xsd.sxbase.XBuiltin

Represents an XSD <xsd:int/> built-in type.

static translate(value, topython=True)
class suds.xsd.sxbuiltin.XLong(schema, name)

Bases: suds.xsd.sxbase.XBuiltin

Represents an XSD <xsd:long/> built-in type.

static translate(value, topython=True)
class suds.xsd.sxbuiltin.XString(schema, name)

Bases: suds.xsd.sxbase.XBuiltin

Represents an XSD <xsd:string/> node.

class suds.xsd.sxbuiltin.XTime(schema, name)

Bases: suds.xsd.sxbase.XBuiltin

Represents an XSD <xsd:time/> built-in type.

static translate(value, topython=True)

Module contents

class suds.xsd.Filter(inclusive=False, *items)
suds.xsd.isqref(object)

Get whether the object is a qualified reference. :param object: An object to be tested. :type object: any :rtype: boolean @see: qualify

suds.xsd.qualify(ref, resolvers, defns=(None, None))

Get a reference that is qualified by namespace. :param ref: A referenced schema type name. :type ref: str :param resolvers: A list of objects to be used to resolve types. :type resolvers: [sax.element.Element,] :param defns: An optional target namespace used to qualify references

when no prefix is specified.
Returns:A qualified reference.
Return type:(name, namespace-uri)