Giter Site home page Giter Site logo

pyxb's Introduction

PyXB -- Python W3C XML Schema Bindings

End-of-life notice

The last release of PyXB was 1.2.6 dated 2017-09-03, with some patches toward an optimistic PyXB 1.2.7 last made 2018-02-11. No maintenance has occured since then, and none is anticipated.

Per #100 (comment) the last version of Python that PyXB works with at all reaches end-of-life soon.

PyXB-X is a fork that may be useful for people who have a dependence on PyXB and need further Python releases.

2023-04-29

pyxb's People

Contributors

jonfoster avatar mbakke avatar pabigot avatar r1mikey avatar wulfgarpro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyxb's Issues

diverging element declarations in a complexType are ignored

I have a schema like this (simplified):

<?xml version="1.0" encoding="iso-8859-1"?>
<xs:schema targetNamespace="http://example.com/test" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Test">
    <xs:complexType>
      <xs:choice>
        <xs:sequence>
          <xs:element name="A" type="xs:string" fixed="0"></xs:element>
          <xs:element name="B" type="xs:string"></xs:element>
        </xs:sequence>
        <xs:element name="A" type="xs:string"></xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>

With the generated binding (pyxb 1.2.4), I can now instantiate Test(A="0", B=""), but I cannot instantiate Test(A="1"), this fails with:

pyxb.exceptions_.ElementChangeError: Value 1 for element A incompatible with fixed content

Excerpt from the generated binding:

CTD_ANON._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(None, 'A'), pyxb.binding.datatypes.string, scope=CTD_ANON, location=pyxb.utils.utility.Location('test.xsd', 7, 5), fixed=True, unicode_default='0'))

CTD_ANON._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(None, 'B'), pyxb.binding.datatypes.string, scope=CTD_ANON, location=pyxb.utils.utility.Location('test.xsd', 8, 5)))

def _BuildAutomaton ():
    # Remove this helper function from the namespace after it is invoked
    global _BuildAutomaton
    del _BuildAutomaton
    import pyxb.utils.fac as fac

    counters = set()
    states = []
    final_update = None
    symbol = pyxb.binding.content.ElementUse(CTD_ANON._UseForTag(pyxb.namespace.ExpandedName(None, 'A')), pyxb.utils.utility.Location('test.xsd', 7, 5))
    st_0 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False)
    states.append(st_0)
    final_update = set()
    symbol = pyxb.binding.content.ElementUse(CTD_ANON._UseForTag(pyxb.namespace.ExpandedName(None, 'B')), pyxb.utils.utility.Location('test.xsd', 8, 5))
    st_1 = fac.State(symbol, is_initial=False, final_update=final_update, is_unordered_catenation=False)
    states.append(st_1)
    final_update = set()
    symbol = pyxb.binding.content.ElementUse(CTD_ANON._UseForTag(pyxb.namespace.ExpandedName(None, 'A')), pyxb.utils.utility.Location('test.xsd', 10, 4))
    st_2 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False)
    states.append(st_2)
    transitions = []
    transitions.append(fac.Transition(st_1, [
     ]))
    st_0._set_transitionSet(transitions)
    transitions = []
    st_1._set_transitionSet(transitions)
    transitions = []
    st_2._set_transitionSet(transitions)
    return fac.Automaton(states, counters, False, containing_state=None)
CTD_ANON._Automaton = _BuildAutomaton()

The problem here seems to be, that there is only one declaration for A element in the binding (CTD_ANON), although there are 2 different declarations in the schema.

SF/162: enhance rename facility

SF/162

In OpenGIS schema tags _foo get renamed to foo to avoid the PyXB namespace reservations. They really ought to be renamed to foo_ to retain the suggestion that they are protected. Either make this a general rule or provide a translation-specific rewrite infrastructure.

SF/227: inadeqate support for wildcard attributes

SF/227

Complex types that supports wildcard attributes do not include those attributes when constructing a DOM representation of the instance.

There also needs to be a public API to set wildcard attributes, just as instance.append() can be used to add DOM nodes to represent wildcard elements.

please add --prefix to setup.py, with /usr/local as default

I am always a bit surprised by software that wants to install itself to /usr instead of /usr/local, but most will accept the --prefix option.

However, this didn't work:
./setup.py --prefix=/usr/local install

I like to keep stuff I download from the internet separate from my package manager's installed files.

I think /usr/local is a saner default than /usr โ€” /usr/local is supposedly for sysadmins, /usr is for distro package maintainers only.

Thread-safe validation disabling

Hi,

I need a thread save option to temporarily disable the parsing validation in PyXB.
Unfortunately pyxb.RequireValidWhenParsing(False) will affect all my threads and thus crash my system. Is there a way to temporarily disable the validation only locally inside a thread?
My current approach looks like:

        try:
            return module.CreateFromDocument(text)
        except:
            pyxb.RequireValidWhenParsing(False)
            data = module.CreateFromDocument(text)
            return data
        finally:
            pyxb.RequireValidWhenParsing(True)

But during the setting to False and the resetting to True my other threads need already RequireValidWhenParsing to be set to True

Thanks for any hints

SF/173: place a limit on non-deterministic expansion

SF/173

Schema that contain the equivalent of (a*)* (as in trac/172) are non-deterministic, and the number of pending unresolved automaton configurations will grow exponentially until a symbol match eliminates some of them. Impose a configurable limit on the amount of non-determinism, and allow the user to control whether exceeding that limit produces an error or simply resolves it arbitrarily.

sf/70: enhance BDS support

SF/70

There are cases where it would be nice to change the default namespace on an inner element of a binding instance that is being converted to XML. BindingDOMSupport currently only allows the default namespace to be specified at the root element.

SF/192: non-global complex types permit names

SF/192

A complex type that is internal to an element with global scope is allowed to have a name attribute, in violation of the constraints which make that attribute prohibited when used as a localComplexType.

SF/86: support wildcard validation

SF/86

The new content model is more accurate, and the previous approach of trying wildcards as a last resort can't be done. Consequently, use of wildcard elements with a namespace constraint of ##other improperly allows non-other elements to be marked as wildcards. Validation prevents this from happening.

Potential Python 3 Issue.

transitionSortKey in generate.py can return a tuple containing None if st is None. On line 340 in generate.py transitions are sorted using transitionSortKey; python 2 would engage in some voodoo to evaluate mistyped inequalities, python 3 does not allow this.

datatypes.decimal call to normalize() destroys trailing zeroes

pyxb's decimal datatype strips trailing zeroes in its XsdLiteral function.

>>> from pyxb.binding.datatypes import decimal
>>> from decimal import Decimal
>>> decimal.XsdLiteral(Decimal('2.000'))
u'2.0'

This is the result of a call to normalize() in the first line of XsdLiteral (binding.datatypes line 159).

(sign, digits, exponent) = value.normalize().as_tuple()

Without normalizing, that is, with:

 (sign, digits, exponent) = value.as_tuple()

the function preserves the zeroes and appears to work fine.

The reason this is an issue for me is because I'm dealing with the Version type from this schema (ctrl+F 'name="Version" type="xs:decimal"' to find it) which is of type decimal. But the service I'm calling demands all 3 zeroes, and chokes if I give it 2.0 instead of 2.000.

Is this expected behavior for pyxb? Does anything else rely on this call to normalize()?

LogicError only when RequireValidWhenGenerating is False

I've set pyxb.RequireValidWhenGenerating(False) at the top of my module so that it disables the expensive validation step when generating an XML document (it takes ~200ms). But the call toxml() always fails with the following exception:

Traceback (most recent call last):
  File "somescript.py", line 236, in send_request
    request.toxml()
  File "/usr/local/lib/python3.4/dist-packages/pyxb/binding/basis.py", line 543, in toxml
    dom = self.toDOM(bds, element_name=element_name)
  File "/usr/local/lib/python3.4/dist-packages/pyxb/binding/basis.py", line 514, in toDOM
    self._toDOM_csc(bds, element)
  File "/usr/local/lib/python3.4/dist-packages/pyxb/binding/basis.py", line 2663, in _toDOM_csc
    content.elementDeclaration.toDOM(dom_support, parent, content.value)
  File "/usr/local/lib/python3.4/dist-packages/pyxb/binding/content.py", line 1106, in toDOM
    raise pyxb.LogicError('toDOM with unrecognized value type %s: %s' % (type(value), value))
pyxb.exceptions_.LogicError: toDOM with unrecognized value type <class 'pyxb.binding.content._PluralBinding'>: [<request.EConfirmTradeType object at 0x7f46f5c8b898>]

The relevant XSD bits for EConfirmTradeType used to generate the data bindings:

248    <xs:complexType name="EConfirmRequestType">
249       <xs:sequence>
250          <xs:element name="EConfirmTrade" type="EConfirmTradeType" maxOccurs="unbounded"/>
251       </xs:sequence>
252       <xs:attribute name="BatchId" type="xs:unsignedLong"/>
253    </xs:complexType>
 517    <xs:complexType name="EConfirmTradeType">
 518       <xs:all>
 519          <xs:element name="SubmissionCompany" type="xs:string" minOccurs="0"/>
 520          <xs:element name="SenderTradeRefId" type="xs:string"/>
 521          <xs:element name="ClientVersionId" type="xs:string" minOccurs="0"/>
 522          <xs:element name="Action" type="ActionType" minOccurs="0"/>
 523          <xs:element name="Comment" type="xs:string" minOccurs="0">
 524             <xs:annotation>
 525                <xs:documentation>Comment supports "Dispute" actions to accomodate
 526                   automated
 527                   match breaks.
 528                </xs:documentation>
 529             </xs:annotation>
 530          </xs:element>
 531          <xs:element name="Type" type="CancelDisputeType" minOccurs="0"/>
 532          <xs:element name="TradeDetail" type="TradeDetailType" minOccurs="0"/>
 533       </xs:all>
 534    </xs:complexType>

The element in question is added in code as:

econfirm_request = request.EConfirmRequest()
econfirm_trade = request.EConfirmTradeType()
# A bunch of assignment statements for sub-elements of econfirm_trade go here
econfirm_request.append(econfirm_trade)

Passing True to RequireValidWhenGenerating or not making that call (I get that the default behavior is to enable validation when generating XML documents) results in a successful toxml() call.

I'm not sure where to begin looking, any ideas?

document preference for file URIs on Windows

In lieu of merging pull request #33 which might produce a behavior change in an untested part of the infrastructure, document that problems processing schema on Windows due to mis-interpretation of filesystem paths as URIs may be avoided by explicitly using file URIs, as exemplified in that request.

Also delete the bogus code visible alongside the proposed patch that was commented out instead of removed late last decade.

SF/229: xsd.QName is not correct

SF/229

The value space is namespace/localname pairs; the lexical space is prefix:localname. Need to inherit from pyxb.namespace.ExpandedName instead of text_type.

This is a blocker because the namespace contexts required to support it are not available. This relates to #12, and is best fixed by a major overhaul that refactors PyXB to closely follow XML infosets.

See also original mail thread.

test-trac-0091 fails on Ubuntu 14.04

For some reason string-to-decimal conversion on this platform is truncating the result, incorrectly failing to discover situations where the literal value exceeds the mandated precision limits for the type.

pyxb/bundles/* not included in install on v1.2.4-dev

Dear Peter,

I am currently trying to package a Python 3 compatible version of pyxb for Debian. Version 1.2.3 was successfully uploaded to the archive, so I started from here and updated the source package with the latest v1.2.4-dev snapshot, which received positive comments in [1].

The package build log complained about missing files in pyxb/bundles/. I investigated further and looked at the python setup.py build output between v1.2.3 [2] and v1.2.4-dev [3]. As you can see, the pyxb.bundles.* packages are detected in v1.2.3 but not in v1.2.4-dev.

Please let me know whether I am missing something here.

Cheers,
Ghis

[1] http://sourceforge.net/p/pyxb/mailman/pyxb-users/?viewmonth=201408

[2] log of setup.py for v1.2.3

ghislain-deb@lat6440-lap:~/Downloads/pyxb-1.2.3+dfsg$ python setup.py build
Found bundle in pyxb/bundles/wssplat
Found bundle in pyxb/bundles/common
Found bundle in pyxb/bundles/dc
Found bundle in pyxb/bundles/saml20
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/pyxb
copying pyxb/exceptions_.py -> build/lib.linux-x86_64-2.7/pyxb
copying pyxb/init.py -> build/lib.linux-x86_64-2.7/pyxb
creating build/lib.linux-x86_64-2.7/pyxb/namespace
copying pyxb/namespace/archive.py -> build/lib.linux-x86_64-2.7/pyxb/namespace
copying pyxb/namespace/init.py -> build/lib.linux-x86_64-2.7/pyxb/namespace
copying pyxb/namespace/builtin.py -> build/lib.linux-x86_64-2.7/pyxb/namespace
copying pyxb/namespace/resolution.py -> build/lib.linux-x86_64-2.7/pyxb/namespace
copying pyxb/namespace/utility.py -> build/lib.linux-x86_64-2.7/pyxb/namespace
creating build/lib.linux-x86_64-2.7/pyxb/binding
copying pyxb/binding/generate.py -> build/lib.linux-x86_64-2.7/pyxb/binding
copying pyxb/binding/xml_.py -> build/lib.linux-x86_64-2.7/pyxb/binding
copying pyxb/binding/saxer.py -> build/lib.linux-x86_64-2.7/pyxb/binding
copying pyxb/binding/facets.py -> build/lib.linux-x86_64-2.7/pyxb/binding
copying pyxb/binding/init.py -> build/lib.linux-x86_64-2.7/pyxb/binding
copying pyxb/binding/content.py -> build/lib.linux-x86_64-2.7/pyxb/binding
copying pyxb/binding/datatypes.py -> build/lib.linux-x86_64-2.7/pyxb/binding
copying pyxb/binding/basis.py -> build/lib.linux-x86_64-2.7/pyxb/binding
creating build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/activestate.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/types_.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/unicode_data.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/init.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/domutils.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/templates.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/utility.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/xmlre.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/saxutils.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/fac.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/unicode.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/saxdom.py -> build/lib.linux-x86_64-2.7/pyxb/utils
creating build/lib.linux-x86_64-2.7/pyxb/xmlschema
copying pyxb/xmlschema/init.py -> build/lib.linux-x86_64-2.7/pyxb/xmlschema
copying pyxb/xmlschema/structures.py -> build/lib.linux-x86_64-2.7/pyxb/xmlschema
creating build/lib.linux-x86_64-2.7/pyxb/bundles
copying pyxb/bundles/init.py -> build/lib.linux-x86_64-2.7/pyxb/bundles
creating build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/wsam.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/wsdl20.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/soapenc.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/wsrf_br.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/wsnt.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/wsdli.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/init.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/mimebind.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/soap11.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/wsa.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/wscoor.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/soapbind11.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/wstop.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/wsu.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/whttp.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/httpbind.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/bpws.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/xenc.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/soapbind12.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/wsdl11.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/wsrm.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/soap12.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/wsdlx.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/wsrf_bf.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/wsp.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/wsoap.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/wsse.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/ds.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
copying pyxb/bundles/wssplat/wsp200607.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat
creating build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsam.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsdl20.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/soapenc.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsrf_br.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsnt.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsdli.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/init.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/mimebind.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/soap11.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsa.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wscoor.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/soapbind11.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wstop.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsu.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/whttp.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/httpbind.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/bpws.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/xenc.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/soapbind12.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsdl11.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsrm.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/soap12.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsdlx.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsrf_bf.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsp.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsoap.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsse.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/ds.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsp200607.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
creating build/lib.linux-x86_64-2.7/pyxb/bundles/common
copying pyxb/bundles/common/xsd_hfp.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/common
copying pyxb/bundles/common/init.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/common
copying pyxb/bundles/common/xhtml1.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/common
copying pyxb/bundles/common/xlink.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/common
creating build/lib.linux-x86_64-2.7/pyxb/bundles/common/raw
copying pyxb/bundles/common/raw/xsd_hfp.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/common/raw
copying pyxb/bundles/common/raw/init.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/common/raw
copying pyxb/bundles/common/raw/xhtml1.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/common/raw
copying pyxb/bundles/common/raw/xlink.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/common/raw
creating build/lib.linux-x86_64-2.7/pyxb/bundles/dc
copying pyxb/bundles/dc/dcmitype.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/dc
copying pyxb/bundles/dc/dc.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/dc
copying pyxb/bundles/dc/init.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/dc
copying pyxb/bundles/dc/dcterms.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/dc
creating build/lib.linux-x86_64-2.7/pyxb/bundles/dc/raw
copying pyxb/bundles/dc/raw/dcmitype.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/dc/raw
copying pyxb/bundles/dc/raw/dc.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/dc/raw
copying pyxb/bundles/dc/raw/init.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/dc/raw
copying pyxb/bundles/dc/raw/dcterms.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/dc/raw
creating build/lib.linux-x86_64-2.7/pyxb/bundles/saml20
copying pyxb/bundles/saml20/x500.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20
copying pyxb/bundles/saml20/xacml.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20
copying pyxb/bundles/saml20/dce.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20
copying pyxb/bundles/saml20/assertion.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20
copying pyxb/bundles/saml20/ecp.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20
copying pyxb/bundles/saml20/init.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20
copying pyxb/bundles/saml20/protocol.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20
copying pyxb/bundles/saml20/metadata.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20
creating build/lib.linux-x86_64-2.7/pyxb/bundles/saml20/raw
copying pyxb/bundles/saml20/raw/x500.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20/raw
copying pyxb/bundles/saml20/raw/xacml.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20/raw
copying pyxb/bundles/saml20/raw/dce.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20/raw
copying pyxb/bundles/saml20/raw/assertion.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20/raw
copying pyxb/bundles/saml20/raw/ecp.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20/raw
copying pyxb/bundles/saml20/raw/init.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20/raw
copying pyxb/bundles/saml20/raw/protocol.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20/raw
copying pyxb/bundles/saml20/raw/metadata.py -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20/raw
copying pyxb/bundles/wssplat/raw/soap11.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsrf_br.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/ds.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/httpbind.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/soap12.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsrf_bf.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/soapbind11.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsp200607.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/mimebind.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsdlx.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsdl20.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wscoor.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/whttp.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsdl11.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsa.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsdli.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsp.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/bpws.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/xenc.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsoap.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wstop.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsnt.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/soapenc.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsu.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsse.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsrm.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/soapbind12.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/wssplat/raw/wsam.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/wssplat/raw
copying pyxb/bundles/common/raw/xhtml1.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/common/raw
copying pyxb/bundles/common/raw/xsd_hfp.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/common/raw
copying pyxb/bundles/common/raw/xlink.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/common/raw
copying pyxb/bundles/dc/raw/dc.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/dc/raw
copying pyxb/bundles/saml20/raw/xacml.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20/raw
copying pyxb/bundles/saml20/raw/x500.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20/raw
copying pyxb/bundles/saml20/raw/ecp.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20/raw
copying pyxb/bundles/saml20/raw/protocol.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20/raw
copying pyxb/bundles/saml20/raw/dce.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20/raw
copying pyxb/bundles/saml20/raw/metadata.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20/raw
copying pyxb/bundles/saml20/raw/assertion.wxs -> build/lib.linux-x86_64-2.7/pyxb/bundles/saml20/raw
running build_scripts
creating build/scripts-2.7
copying and adjusting scripts/pyxbgen -> build/scripts-2.7
copying and adjusting scripts/pyxbwsdl -> build/scripts-2.7
copying and adjusting scripts/pyxbdump -> build/scripts-2.7
changing mode of build/scripts-2.7/pyxbgen from 644 to 755
changing mode of build/scripts-2.7/pyxbwsdl from 644 to 755
changing mode of build/scripts-2.7/pyxbdump from 644 to 755

[3] log of setup.py for v1.2.4-dev

ghislain-deb@lat6440-lap:/Downloads/pyxb-1.2.4dev+dfsg$ python setup.py build
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/pyxb
copying pyxb/exceptions_.py -> build/lib.linux-x86_64-2.7/pyxb
copying pyxb/init.py -> build/lib.linux-x86_64-2.7/pyxb
creating build/lib.linux-x86_64-2.7/pyxb/namespace
copying pyxb/namespace/archive.py -> build/lib.linux-x86_64-2.7/pyxb/namespace
copying pyxb/namespace/init.py -> build/lib.linux-x86_64-2.7/pyxb/namespace
copying pyxb/namespace/builtin.py -> build/lib.linux-x86_64-2.7/pyxb/namespace
copying pyxb/namespace/resolution.py -> build/lib.linux-x86_64-2.7/pyxb/namespace
copying pyxb/namespace/utility.py -> build/lib.linux-x86_64-2.7/pyxb/namespace
creating build/lib.linux-x86_64-2.7/pyxb/binding
copying pyxb/binding/generate.py -> build/lib.linux-x86_64-2.7/pyxb/binding
copying pyxb/binding/xml_.py -> build/lib.linux-x86_64-2.7/pyxb/binding
copying pyxb/binding/saxer.py -> build/lib.linux-x86_64-2.7/pyxb/binding
copying pyxb/binding/facets.py -> build/lib.linux-x86_64-2.7/pyxb/binding
copying pyxb/binding/init.py -> build/lib.linux-x86_64-2.7/pyxb/binding
copying pyxb/binding/content.py -> build/lib.linux-x86_64-2.7/pyxb/binding
copying pyxb/binding/datatypes.py -> build/lib.linux-x86_64-2.7/pyxb/binding
copying pyxb/binding/basis.py -> build/lib.linux-x86_64-2.7/pyxb/binding
creating build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/activestate.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/unicode_data.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/init.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/domutils.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/templates.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/utility.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/xmlre.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/six.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/saxutils.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/fac.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/unicode.py -> build/lib.linux-x86_64-2.7/pyxb/utils
copying pyxb/utils/saxdom.py -> build/lib.linux-x86_64-2.7/pyxb/utils
creating build/lib.linux-x86_64-2.7/pyxb/xmlschema
copying pyxb/xmlschema/init.py -> build/lib.linux-x86_64-2.7/pyxb/xmlschema
copying pyxb/xmlschema/structures.py -> build/lib.linux-x86_64-2.7/pyxb/xmlschema
creating build/lib.linux-x86_64-2.7/pyxb/bundles
copying pyxb/bundles/init.py -> build/lib.linux-x86_64-2.7/pyxb/bundles
running build_scripts
creating build/scripts-2.7
copying and adjusting scripts/pyxbgen -> build/scripts-2.7
copying and adjusting scripts/pyxbwsdl -> build/scripts-2.7
copying and adjusting scripts/pyxbdump -> build/scripts-2.7
changing mode of build/scripts-2.7/pyxbgen from 644 to 755
changing mode of build/scripts-2.7/pyxbwsdl from 644 to 755
changing mode of build/scripts-2.7/pyxbdump from 644 to 755

"mc:Ignorable" causes UnrecognizedAttributeError in EMCA-376 document

Using Word 2013, I created a very simple .docx. I extracted the .docx, and attempted to load word/document.xml using the binding classes I generated using pyxbgen from the transitional schema files. This causes pyxb to raise UnrecognizedAttributeError apparently due to the mc:Ignorable attribute on the document element:

<w:document xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"  xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" mc:Ignorable="w14 w15 wp14">

I'm able to avoid this exception and load the document by removing the mc:Ignorable because the namespaces defined in the ignorable are not being used in this particular document. I do have other documents which reference these other ignorable namespaces, which causes pyxb to fail.

Traceback:

----> 1 result = w.CreateFromDocument(data)

/home/kyle/dev/pydocx/transitional/w.pyc in CreateFromDocument(xml_text, default_namespace, location_base)
     60     if isinstance(xmld, _six.text_type):
     61         xmld = xmld.encode(pyxb._InputEncoding)
---> 62     saxer.parse(io.BytesIO(xmld))
     63     instance = handler.rootObject()
     64     return instance

/home/kyle/.pyenv/versions/2.7.6/lib/python2.7/xml/sax/expatreader.pyc in parse(self, source)
    105         self.reset()
    106         self._cont_handler.setDocumentLocator(ExpatLocator(self))
--> 107         xmlreader.IncrementalParser.parse(self, source)
    108
    109     def prepareParser(self, source):

/home/kyle/.pyenv/versions/2.7.6/lib/python2.7/xml/sax/xmlreader.pyc in parse(self, source)
    121         buffer = file.read(self._bufsize)
    122         while buffer != "":
--> 123             self.feed(buffer)
    124             buffer = file.read(self._bufsize)
    125         self.close()

/home/kyle/.pyenv/versions/2.7.6/lib/python2.7/xml/sax/expatreader.pyc in feed(self, data, isFinal)
    208             # document. When feeding chunks, they are not normally final -
    209             # except when invoked from close.
--> 210             self._parser.Parse(data, isFinal)
    211         except expat.error, e:
    212             exc = SAXParseException(expat.ErrorString(e.code), e, self)

/home/kyle/.pyenv/versions/2.7.6/lib/python2.7/xml/sax/expatreader.pyc in start_element_ns(self, name, attrs)
    339
    340         self._cont_handler.startElementNS(pair, None,
--> 341                                           AttributesNSImpl(newattrs, qnames))
    342
    343     def end_element_ns(self, name):

/home/kyle/.pyenv/versions/2.7.6/lib/python2.7/site-packages/pyxb/binding/saxer.pyc in startElementNS(self, name, qname, attrs)
    368         # Process the element start.  This may or may not return a
    369         # binding object.
--> 370         binding_object = this_state.startBindingElement(type_class, new_object_factory, element_decl, attrs)
    371
    372         # If the top-level element has complex content, this sets the

/home/kyle/.pyenv/versions/2.7.6/lib/python2.7/site-packages/pyxb/binding/saxer.pyc in startBindingElement(self, type_class, new_object_factory, element_decl, attrs)
    205             try:
    206                 pyxb.namespace.NamespaceContext.PushContext(self.namespaceContext())
--> 207                 self.__constructElement(new_object_factory, attrs)
    208             finally:
    209                 pyxb.namespace.NamespaceContext.PopContext()

/home/kyle/.pyenv/versions/2.7.6/lib/python2.7/site-packages/pyxb/binding/saxer.pyc in __constructElement(self, new_object_factory, attrs, content)
    133             # The binding instance may be a simple type that does not support
    134             # attributes; the following raises an exception in that case.
--> 135             self.__bindingInstance._setAttribute(attr_en, attrs.getValue(attr_name))
    136
    137         return self.__bindingInstance

/home/kyle/.pyenv/versions/2.7.6/lib/python2.7/site-packages/pyxb/binding/basis.pyc in _setAttribute(self, attr_en, value_lex)
   2236             if self._AttributeWildcard is None:
   2237                 import ipdb; ipdb.set_trace()
-> 2238                 raise pyxb.UnrecognizedAttributeError(type(self), attr_en, self)
   2239             self.__wildcardAttributeMap[attr_en] = value_lex
   2240         else:

UnrecognizedAttributeError: (<class '_nsgroup_.CT_Document'>, <pyxb.namespace.ExpandedName object at 0x2020bd0>, <_nsgroup_.CT_Document object at 0x2020450>, pyxb.utils.utility.Location(None, 2, 0))

The traceback doesn't actually indicate the attribute name, which itself is unfortunate. attr_en is passed in the exception, but it's not evaluated unless you convert it to a string. I used a ipdb.set_trace (apparent in the above traceback) to reveal the attribute name.

xsi:type not managed properly when base type is not abstract

Consider the following schema (customer.xsd):

<?xml version="1.0" encoding="UTF-8"?>
<schema 
    xmlns="http://www.w3.org/2001/XMLSchema" 
    targetNamespace="http://www.example.org/customer" 
    xmlns:tns="http://www.example.org/customer" 
    elementFormDefault="qualified">

    <element name="customer">
        <complexType>
            <sequence>
                <element name="address" type="tns:address"/>
            </sequence>
        </complexType>
    </element>

    <complexType name="address">
        <sequence>
            <element name="street" type="string"/>
        </sequence>
    </complexType>

    <complexType name="canadianAddress">
        <complexContent>
            <extension base="tns:address">
                <sequence>
                    <element name="postalCode" type="string"/>
                </sequence>
            </extension>
        </complexContent>
    </complexType>

</schema>

It defines an type address and a derived type canadianAddress.

A valid XML document reads as follows:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customer xmlns="http://www.example.org/customer">
    <address xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="canadianAddress">
        <street>1 A Street</street>
        <postalCode>Ontario</postalCode>
    </address>
</customer>

Generating the bindings with PyXB 1.2.4:

python /tmp/PyXB-1.2.4/scripts/pyxbgen -u customer.xsd -m customer

PyXB is able to read the XML properly, but fails to encode it back to XML (attribute "xsi:type") is missing:

>>> import customer
>>> x = customer.CreateFromDocument(open("customer.xml").read())
>>> x.address
<customer.canadianAddress object at 0x16ccdd0>
>>> print x.toxml()
<?xml version="1.0" ?>
<ns1:customer xmlns:ns1="http://www.example.org/customer"><ns1:address><ns1:street>1 A Street</ns1:street><ns1:postalCode>Ontario</ns1:postalCode></ns1:address></ns1:customer>

Looking at the code I can see that a class must be abstract to require xsi:type attribute, but to my knowledge a non-abstract type could require it as well:

 325     @classmethod
 326     def _RequireXSIType (cls, value_type):
 327         if cls._IsUrType():
 328             # Require xsi:type if value refines xs:anyType
 329             return value_type != cls
 330         return cls._Abstract and value_type != cls._SupersedingClass()

I tried removing the abstract condition, but then the code fails for xsd:union types.

float/double: generate canonical representation of non-special values

The canonical representation of xsd float and double values is always of the form [-]#.#+E[-]#+. There is no sane way to generate this from existing Python numeric formatting support, so PyXB currently uses the default formatting instead. For validation purposes it probably should try harder.

property in class must deconflict from module identifier

The following schema fragment:

<xs:simpleType name="name">
  <xs:restriction base="xs:string" />
</xs:simpleType>
<xs:element name="Container">
  <xs:complexType>
    <xs:attribute name="name" type="name"/>
    <xs:attribute name="name2" type="name"/>
  </xs:complexType>
</xs:element>

generates code where the attribute use of the name2 is defined using unadorned name as the type parameter. In context this resolves to the Container type property name corresponding to its attribute name, not the module-level simple type name.

pyxb stubs contain implicit relative imports on python 3

When generating the "Import bindings for namespaces imported into schema" section, pyxb writes out implicit relative imports to import modules in the current directory. This doesn't work on python 3.

I tried to just change https://github.com/pabigot/pyxb/blob/next/pyxb/binding/generate.py#L1356 to from . import .. but then apparently the test harness uses eval?! and so because python perceives the test code as not in a package you get an error SystemError: Parent module '' not loaded, cannot perform relative import.

pyxbgen: Problem with paths containing dots

Hi,

First of all thanks for pyxb!

I have encountered a problem with the way pyxbgen handles filesystem paths containing dots. Consider the following command:

$ scripts/pyxbgen -u /tmp/test.dir/config.xsd -m /tmp/test.dir/generated/config

config.xsd can be any schema.

Instead of creating the requested /tmp/test.dir/generated/config.py module, a file named /tmp/test/dir/generated/config.py is created. I traced the problem to the split('.') operations in generate.py but I had trouble understanding the intention of the code.

Thanks!
reet

AssertionError: name tns:customValue

Generating bindings from the following WSDL (http://wiws.cmbi.umcn.nl/wsdl) results in the error:

AssertionError: name tns:customValue

I'm not sure if this is a WSDL problem or a PyXB problem. The WSDL does have xmlns:tns="..." at the beginning.

<wsdl:definitions targetNamespace="http://swift.cmbi.ru.nl/wiws" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://swift.cmbi.ru.nl/wiws" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:sawsdl="http://www.w3.org/ns/sawsdl">

I'm using version 1.2.3 installed via pip.

The full stack trace is:

Retrieving WSDL from http://wiws.cmbi.ru.nl/wsdl
WARNING:pyxb.binding.basis:Unable to convert DOM node {http://www.w3.org/2001/XMLSchema}schema at wsdl[3:4] to binding
WARNING:pyxb.binding.basis:Unable to convert DOM node {http://www.w3.org/ns/sawsdl}attrExtensions at wsdl[2873:6] to binding
PS urn:uuid:239c8f3e-4498-11e4-9de8-842b2b9f326f
Traceback (most recent call last):
File "/home/jon/.virtualenvs/hope-flask/bin/pyxbgen", line 51, in
generator.resolveExternalSchema()
File "/home/jon/.virtualenvs/hope-flask/local/lib/python2.7/site-packages/pyxb/binding/generate.py", line 2647, in resolveExternalSchema
schema = converter(self, sl)
File "/home/jon/.virtualenvs/hope-flask/bin/pyxbgen", line 28, in WSDLToSchema
spec = wsdl.definitions.createFromDOM(pyxb.utils.domutils.StringToDOM(xmld, location_base=wsdl_uri), process_schema=True, generation_uid=generator.generationUID())
File "/home/jon/.virtualenvs/hope-flask/local/lib/python2.7/site-packages/pyxb/binding/basis.py", line 1767, in createFromDOM
return self._createFromDOM(node, expanded_name, *_kw)
File "/home/jon/.virtualenvs/hope-flask/local/lib/python2.7/site-packages/pyxb/binding/basis.py", line 1791, in _createFromDOM
return element.CreateDOMBinding(node, self.elementForName(expanded_name), *_kw)
File "/home/jon/.virtualenvs/hope-flask/local/lib/python2.7/site-packages/pyxb/binding/basis.py", line 1681, in CreateDOMBinding
rv = type_class.Factory(_dom_node=node, *_kw)
File "/home/jon/.virtualenvs/hope-flask/local/lib/python2.7/site-packages/pyxb/binding/basis.py", line 308, in Factory
rv._postFactory_vx(state)
File "/home/jon/.virtualenvs/hope-flask/local/lib/python2.7/site-packages/pyxb/bundles/wssplat/wsdl11.py", line 224, in _postFactory_vx
self.__processSchema(generation_uid)
File "/home/jon/.virtualenvs/hope-flask/local/lib/python2.7/site-packages/pyxb/bundles/wssplat/wsdl11.py", line 288, in __processSchema
self.__schema = pyxb.xmlschema.schema.CreateFromDOM(wc, namespace_context=self.namespaceContext(), generation_uid=generation_uid)
File "/home/jon/.virtualenvs/hope-flask/local/lib/python2.7/site-packages/pyxb/xmlschema/structures.py", line 4858, in CreateFromDOM
rv = schema.__processTopLevelNode(cn)
File "/home/jon/.virtualenvs/hope-flask/local/lib/python2.7/site-packages/pyxb/xmlschema/structures.py", line 5037, in __processTopLevelNode
return self._addNamedComponent(component.CreateFromDOM(node, *_kw))
File "/home/jon/.virtualenvs/hope-flask/local/lib/python2.7/site-packages/pyxb/xmlschema/structures.py", line 2053, in CreateFromDOM
return rv.__setContentFromDOM(node, *_kw)
File "/home/jon/.virtualenvs/hope-flask/local/lib/python2.7/site-packages/pyxb/xmlschema/structures.py", line 2459, in __setContentFromDOM
self.__setComplexContentFromDOM(node, content_node, definition_node_list, self.__pendingDerivationMethod, *_kw)
File "/home/jon/.virtualenvs/hope-flask/local/lib/python2.7/site-packages/pyxb/xmlschema/structures.py", line 2303, in __setComplexContentFromDOM
effective_content = Particle.CreateFromDOM(typedef_node, *_kw)
File "/home/jon/.virtualenvs/hope-flask/local/lib/python2.7/site-packages/pyxb/xmlschema/structures.py", line 3141, in CreateFromDOM
rv.__term = ModelGroup.CreateFromDOM(node, *_kw)
File "/home/jon/.virtualenvs/hope-flask/local/lib/python2.7/site-packages/pyxb/xmlschema/structures.py", line 2884, in CreateFromDOM
particles.append(Particle.CreateFromDOM(node=cn, *_kw))
File "/home/jon/.virtualenvs/hope-flask/local/lib/python2.7/site-packages/pyxb/xmlschema/structures.py", line 3123, in CreateFromDOM
rv.__term = ElementDeclaration.CreateFromDOM(node=node, *_kw)
File "/home/jon/.virtualenvs/hope-flask/local/lib/python2.7/site-packages/pyxb/xmlschema/structures.py", line 1590, in CreateFromDOM
rv = cls(name=name, node=node, **kw)
File "/home/jon/.virtualenvs/hope-flask/local/lib/python2.7/site-packages/pyxb/xmlschema/structures.py", line 1556, in init
super(ElementDeclaration, self).init(_args, *_kw)
File "/home/jon/.virtualenvs/hope-flask/local/lib/python2.7/site-packages/pyxb/xmlschema/structures.py", line 170, in init
super(_SchemaComponent_mixin, self).init(_args, *_kw)
File "/home/jon/.virtualenvs/hope-flask/local/lib/python2.7/site-packages/pyxb/xmlschema/structures.py", line 764, in init
assert (name is None) or (0 > name.find(':')), 'name %s' % (name,)
AssertionError: name tns:customValue

invalid syntax generated for an ubl invoice 2.1

Hi,

First good job setting up such a nice tool.

I have an issue with the schema for ubl invoices, it works for ubl 2.0 but not ubl 2.1

here you have the schema http://docs.oasis-open.org/ubl/os-UBL-2.1/xsd/

and I have this exception when I try to import the module generated by pyxbgen

  File "/home/malik/fteam_project/Fteam/utils/ubl/ubl_reader.py", line 1, in <module>
    from utils.ubl.ubl21 import invoice as ubl_invoice
  File "/home/malik/fteam_project/Fteam/utils/ubl/ubl21/invoice.py", line 27, in <module>
    import utils.ubl.ubl21._cac as _ImportedBinding_utils_ubl_ubl21__cac
  File "/home/malik/fteam_project/Fteam/utils/ubl/ubl21/_cac.py", line 27, in <module>
    import utils.ubl.ubl21._cbc as _ImportedBinding_utils_ubl_ubl21__cbc
  File "/home/malik/fteam_project/Fteam/utils/ubl/ubl21/_cbc.py", line 28, in <module>
    import utils.ubl.ubl21._udt as _ImportedBinding_utils_ubl_ubl21__udt
  File "/home/malik/fteam_project/Fteam/utils/ubl/ubl21/_udt.py", line 27
    import utils.ubl.ubl21._ccts-cct as _ImportedBinding_utils_ubl_ubl21__ccts_cct
                                ^
SyntaxError: invalid syntax

I generated this module this way:

pyxbgen -u ../extra/docs.oasis-open.org/ubl/os-UBL-2.1/xsd/maindoc/UBL-Invoice-2.1.xsd -m invoice --module-prefix=utils.ubl.ubl21
WARNING:pyxb.binding.generate:Complex type {urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2}ContractingPartyType renamed to ContractingPartyType_
Python for urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 requires 13 modules

is it safe to just rename the module ?
if yes how does it impact the rest of the generated code ?

thanks

ps: I renamed it with an underscore instead of the dash and it seems to work fine

Performance issue when parsing large base64Binary data

Hello,
I have experienced performance issues when trying uploading large files.
For example, say we have the following schema:
<xsd:complexType name="uploadFileRequest">
<xsd:sequence>
<xsd:element name="file" type="xsd:base64Binary" minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>

When the file is large, say 7MB, I can notice significant performance issue. I have located the problem to CreateFromDocument() function which is generated by pyxb. It is used to "Parse the given XML and use the document element to create a Python instance".

More specifically, it is the following line in the above method which takes majority of the time to execute:
saxer.parse(io.BytesIO(xmld))
where xmld is the xml string that is passed into this function.

I posted this issue on Source Forge,
thanks @pabigot for pointing out that it is the regex match that is costing the majority of the time.

# This is what it costs to try to be a validating processor.
if cls.__Lexical_re.match(xmlt) is None:
raise SimpleTypeValueError(cls, xmlt)

If we comment this code block out, this issue is fixed. However, since the above code is about "As PyXB is a validating processor it must check whether the incoming encoded data is a valid XML representation. (Peter)", it would be good to have a workaround for this to be part of future releases.

Thanks a lot for your help! @pabigot

Cheers,
James

datatypes: float/decimal non-number values incorrect

From direct email:

In section 3.2.4.1 of the following document http://www.w3.org/TR/xmlschema-2/#float it states that allowed special values for floats in xml files are "INF", "-INF" and "NaN".
Pyxb seems to convert "INF" to "inf". I have not tested the other values, but suspect similar behavior.
As this violates the xml standard I would like to ask kindly, whether you could fix this bug in pyxb. Other parsers fail on this value. (Tested on MSxml)

Also note constraints on canonical lexical representation that are probably not handled.

Please add toprettyxml

Hi,
I recently started using your library. It is very nice, thanks a lot.

Would it be possible to add toprettyxml in addition to toxml?

Randomness, is there a reason in six.py line 482 the param passed is triple quoted instead of single quoated?

Also structures.py line 1753 has a messed up doc string. It is "doc""" instead of """doc"""

Thanks for such a nice library
have fun

datatypes: float/double do not validate special values

PyXB uses the underlying Python float type to represent xsd float and double values. This accepts both the canonical spellings INF, -INF, NaN as well as case-varying alternatives and full words Infinity. It should reject everything but the canonical name.

SF/101: need facility to customize reserved symbols

SF/101

PyXB deconflicts XML symbols from Python reserved words (like class) and from attribute identifiers that PyXB uses (like value and content). It does not deconflict symbols that Python might use but that are not reserved, such as str, list, and property. Thus XML elements and types with these names may create conflicts.

PyXB should not be obliged to guess every identifier that might have a global use, so it needs a way for the developer to extend the reserved symbols list when generating bindings for a schema.

CreateFromDocument crashes using binary types with zero-length data

Sample schema (this also happens with base64Binary):

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="test">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="bin" type="xs:hexBinary"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

Compile bindings:

pyxbgen test.xsd -m test_binding

Read document:

import test_binding
test_binding.CreateFromDocument(open('test.xml').read()).bin

The following XML samples work:

<test><bin>aa</bin></test>
<test><bin> </bin></test>

The following don't:

<test><bin></bin></test>
<test><bin/></test>

Traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "test_binding.py", line 62, in CreateFromDocument
    saxer.parse(io.BytesIO(xmld))
  File "C:\Python27\lib\xml\sax\expatreader.py", line 110, in parse
    xmlreader.IncrementalParser.parse(self, source)
  File "C:\Python27\lib\xml\sax\xmlreader.py", line 123, in parse
    self.feed(buffer)
  File "C:\Python27\lib\xml\sax\expatreader.py", line 213, in feed
    self._parser.Parse(data, isFinal)
  File "C:\Python27\lib\xml\sax\expatreader.py", line 365, in end_element_ns
    self._cont_handler.endElementNS(pair, None)
  File "pyxb\binding\saxer.py", line 388, in endElementNS
    binding_object = this_state.endBindingElement()
  File "pyxb\binding\saxer.py", line 226, in endBindingElement
    self.__constructElement(self.__delayedConstructor, self.__attributes, args)
  File "pyxb\binding\saxer.py", line 116, in __constructElement
    self.__bindingInstance = new_object_factory(*content, **kw)
  File "pyxb\binding\basis.py", line 1600, in __call__
    rv = self.typeDefinition().Factory(*args, **kw)
  File "pyxb\binding\basis.py", line 305, in Factory
    rv = cls._DynamicCreate(*args, **kw)
  File "pyxb\binding\basis.py", line 677, in _DynamicCreate
    return ctor(*args, **kw)
  File "pyxb\binding\basis.py", line 873, in __new__
    args = cls._ConvertArguments(args, kw)
  File "pyxb\binding\basis.py", line 851, in _ConvertArguments
    return cls._ConvertArguments_vx(args, kw)
  File "pyxb\binding\datatypes.py", line 810, in _ConvertArguments_vx
    xmlt = args[0]
IndexError: tuple index out of range

It looks like the problem is that the SAX handler's ContentHandler.characters doesn't get called with the empty string for an empty element so args is ending up empty. The simplest fix is to handle that in hexBinary and base64Binary but I really have no idea how much more of the code is affected by this.

failure in python deepcopy

This SF forum post notes that a deep copy of a binding instance that involves absent namespaces produces a serialization error. There's probably some magic method that can be added to tell deepcopy how to proceed.

assertion failure generating extension bindings

The bindings for http://www.w3.org/2005/Atom are generated as a side effect of the bindings for http://www.opengis.net/kml/2.2. The assertion below fails when building extension bindings for the latter namespace, as described in this SO question:

File "/opt/pyxb/pyxb/binding/generate.py", line 1520, in importForDeclaration
assert sdecl._objectOrigin().moduleRecord().namespace() == ns

Chances are this assertion is simply being too strict, or the correct namespace should be located elsewhere.

How to BIND QName with namespace

Hi,

thanks for the effort you put into this library.

I'm trying to generate something like this:

<fes:GeometryOperand xmlns:ns="http://www.opengis.net/gml/3.2" name="ns:Envelope" />

At the moment I'm using pyxb.BIND(name="Envelope") which of course doesn't add the namespace. What's the correct / easiest way for that use case?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.