On Wed, Oct 19, 2011 at 11:22 AM, Marcin Tustin <marcin.tus...@gmail.com>wrote:
> Hi Peter,
>
> Thanks for this. Unless I'm mistaken, namespace URIs are not required to
> map to any resource at all, let alone an XSD. However, the xsd from which
> I'm generating the code is at
> http://xmlgw.companieshouse.gov.uk/v2-1/schema/Egov_ch-v2-0.xsd.
>
That schema is for namespace http://www.govtalk.gov.uk/CM/envelope.
What is PyXB expecting in its input that could be leading to this? Does it
> rely on namespaces naming XSD files?
>
No, PyXB treats namespaces as URIs, not URLs, and has no expectation that
they can be dereferenced. (It may, when generating bindings, make some
attempt to locate the schema from an xsi:schemaLocation attribute, but that
shouldn't happen when parsing.)
The example documents (from the link you provided) do not reference the
namespace http://www.govtalk.gov.uk/CM/
envelope. They both specify that the default namespace is
http://www.govtalk.gov.uk/schemas/govtalk/govtalkheader. Unless you have a
schema for that namespace, PyXB won't be able to decode the content of the
document.
If the document doesn't specify a default namespace I believe it would fall
back to the one you used as the CreateFromDocument call, but when the
document does specify a namespace it's expected to be correct.
Try editing the document and correcting the xmlns= attribute at the root so
it has the same namespace as the module you're using to parse it.
Peter
>
> On Wed, Oct 19, 2011 at 16:49, Peter Bigot <big...@acm.org> wrote:
>
>> On Wed, Oct 19, 2011 at 10:32 AM, Marcin Tustin
>> <marcin.tus...@gmail.com>wrote:
>>
>>> Hi all,
>>>
>>> I'm making my first contact with pyxb, and so far it seems to only exist
>>> to generate odd errors.
>>>
>>> I've tried to have it parse a document with:
>>>
>>> > import govtalkenvelope as g
>>> > g.CreateFromDocument("""[xml taken from
>>> http://xmlgw.companieshouse.gov.uk/example_http.html]""")
>>> Traceback (most recent call last):
>>> File "<stdin>", line 35, in <module>
>>> File "govtalkenvelope.py", line 32, in CreateFromDocument
>>> saxer.parse(StringIO.StringIO(xml_text))
>>> File "C:\Python27\Lib\xml\sax\expatreader.py", line 107, 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 207, in feed
>>> self._parser.Parse(data, isFinal)
>>> File "C:\Python27\Lib\xml\sax\expatreader.py", line 338, in
>>> start_element_ns
>>> AttributesNSImpl(newattrs, qnames))
>>> File
>>> "C:\Users\Marcin\Documents\oneclickcos\lib\site-packages\pyxb\binding\sax
>>> er.py", line 310, in startElementNS
>>> element_binding = name_en.elementBinding()
>>> File
>>> "C:\Users\Marcin\Documents\oneclickcos\lib\site-packages\pyxb\namespace\_
>>> _init__.py", line 96, in __getattr__
>>> category_value =
>>> self.namespace().categoryMap(name).get(self.localName())
>>> File
>>> "C:\Users\Marcin\Documents\oneclickcos\lib\site-packages\pyxb\namespace\_
>>> _init__.py", line 293, in categoryMap
>>> raise pyxb.NamespaceError(self, '%s has no category %s' % (self,
>>> category))
>>> pyxb.exceptions_.NamespaceError:
>>> http://www.govtalk.gov.uk/schemas/govtalk/govta
>>> lkheader has no category elementBinding
>>>
>>
>> It's probably saying it doesn't know how to deal with the
>> http://www.govtalk.gov.uk/schemas/govtalk/govtalkheader namespace.
>> Certainly it isn't clear to me where to find a schema for that namespace;
>> the xsiLocation URI in the sample resolves to a web page, not a schema.
>>
>> Did you generate bindings for that namespace? How?
>>
>>
>>>
>>> Needless to say, it's less than clear what this is supposed to mean. Any
>>> suggestions as to what might be causing this, or indeed how in general to
>>> deal with pyxb's exception messages?
>>>
>>
>> Experience is the only guide. Sorry, PyXB development is unfunded, so
>> making it user friendly hasn't gotten much attention.
>>
>> Peter
>>
>>
>>>
>>> Marcin
>>>
>>> --
>>> Marcin Tustin
>>> Tel: 07773 787 105
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> All the data continuously generated in your IT infrastructure contains a
>>> definitive record of customers, application performance, security
>>> threats, fraudulent activity and more. Splunk takes this data and makes
>>> sense of it. Business sense. IT sense. Common sense.
>>> http://p.sf.net/sfu/splunk-d2d-oct
>>> _______________________________________________
>>> pyxb-users mailing list
>>> pyxb-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/pyxb-users
>>>
>>>
>>
>
>
> --
> Marcin Tustin
> Tel: 07773 787 105
>
>
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
_______________________________________________
pyxb-users mailing list
pyxb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyxb-users