The following shell script may be useful to help build your schema by
re-using the base AIXM namespace in the same way as the OpenGIS ones are
re-used.
if [ ! -f aixm.py ] ; then
pyxbgen \
--uri-content-archive-directory aixm.downloaded \
--archive-path '&pyxb/bundles/opengis//:+' \
--schema-location
http://www.aixm.aero/gallery/content/public/schema/5.0/AIXM_Features.xsd \
--archive-to-file aixm.wxs \
--module aixm
fi
if [ ! -f saa.py ] ; then
pyxbgen \
--uri-content-archive-directory saa.downloaded \
--archive-path '.:&pyxb/bundles/opengis//:+' \
--archive-to-file saa.wxs \
--schema-location
http://wendell-y.rho.net/aixm/SAA_AIXM_5_Schemas/SAA-Message.xsd \
--module saa
fi
The following python script, when used with PyXB 1.1.1, should help
locate problems like the unhandled SUA namespace content:
import pyxb
import urllib2
import saa
xml =
urllib2.urlopen('http://wendell-y.rho.net/aixm/SAA_AIXM_5_Schemas/sample-Snowbird.xml').read()
try:
order = saa.CreateFromDocument(xml)
print order
except pyxb.UnrecognizedContentError, e:
loc = e.content.location
print 'Unrecognized %s at %s line %d column %d' % (e.content.name,
loc.locationBase, loc.lineNumber, loc.columnNumber)
I get something like the following when running it:
Unrecognized (u'urn:us:gov:dot:faa:aim:saa:sua', u'AirspaceExtension')
at None line 79 column 6
On 1/27/2010 4:19 PM, Wendell Turner wrote:
> The parser doesn't like the second 'aixm:extension' field. If I
> comment it out, as:
> <!-- aixm:extension>
> <aimsua:AirspaceExtension
> gml:id="Airspace01_TS1_SUA_EXT">
> <aimsua:suaType>MOA</aimsua:suaType>
> </aimsua:AirspaceExtension>
> </aixm:extension -->
>
> The document parses. If this is an error in the sample
> file, I'll bring it up with the authors of that file.
>
> Wendell
>
>
> On Wed, Jan 27, 2010 at 10:58:58PM +0000, Wendell Turner wrote:
>
>> Thank you very much for your help. I'm not sure about the schema
>> or the samples, but I would guess that they worked in some xml
>> parser somewhere.
>>
>> I see that the schema used in pyxbgen should be SAA-Message.xsd
>> instead of SAA-Feature.xsd. With that change, it gets the error
>> shown below. Is there a way to turn on debugging or set verbose
>> to see what it is complaining about?
>>
>> Thanks again,
>>
>> Wendell
>>
>> Traceback (most recent call last):
>> File "./read_msg.py", line 18, in ?
>> order = saamsg.CreateFromDocument(xml)
>> File "/home/wendell/pyxb/y_rho_net/saamsg.py", line 34, in
>> CreateFromDocument
>> saxer.parse(StringIO.StringIO(xml_text))
>> File "/usr/lib/python2.4/xml/sax/expatreader.py", line 107, in parse
>> xmlreader.IncrementalParser.parse(self, source)
>> File "/usr/lib/python2.4/xml/sax/xmlreader.py", line 123, in parse
>> self.feed(buffer)
>> File "/usr/lib/python2.4/xml/sax/expatreader.py", line 207, in feed
>> self._parser.Parse(data, isFinal)
>> File "/usr/lib/python2.4/xml/sax/expatreader.py", line 348, in
>> end_element_ns
>> self._cont_handler.endElementNS(pair, None)
>> File "/usr/lib/python2.4/site-packages/pyxb/binding/saxer.py", line 360,
>> in endElementNS
>> binding_object = this_state.endBindingElement()
>> File "/usr/lib/python2.4/site-packages/pyxb/binding/saxer.py", line 213,
>> in endBindingElement
>> self.__bindingObject.append(content, element_use, maybe_element,
>> require_validation=pyxb._ParsingRequiresValid)
>> File "/usr/lib/python2.4/site-packages/pyxb/binding/basis.py", line 1999,
>> in append
>> if self.__dfaStack.step(self, value, element_use):
>> File "/usr/lib/python2.4/site-packages/pyxb/binding/content.py", line
>> 636, in step
>> ok = self.topModelState().step(self, ctd_instance, value, element_use)
>> File "/usr/lib/python2.4/site-packages/pyxb/binding/content.py", line
>> 512, in step
>> self.__state = self.contentModel().step(ctd_instance, self.state(),
>> value, element_use, dfa_stack)
>> File "/usr/lib/python2.4/site-packages/pyxb/binding/content.py", line
>> 994, in step
>> return self.__stateMap[state].evaluateContent(ctd_instance, value,
>> element_use, dfa_stack)
>> File "/usr/lib/python2.4/site-packages/pyxb/binding/content.py", line
>> 967, in evaluateContent
>> raise pyxb.UnrecognizedContentError(value)
>> pyxb.exceptions_.UnrecognizedContentError:<pyxb.utils.saxdom.Element object
>> at 0xa3a96cc>
>>
>>
>>
>> On Wed, Jan 27, 2010 at 03:33:27PM -0700, Peter A. Bigot wrote:
>>
>>> It appears the schema for the urn:us:gov:dot:faa:aim:saa namespace are
>>> incomplete. The example document starts with an element SaaMessage in
>>> that namespace, but the entrypoint schema you gave does not define that
>>> element, nor do the schema it includes. Without a defined element by
>>> that name, or an xsi:type attribute on the document element, PyXB
>>> creates a generic DOM-compatible instance as the root object, and since
>>> that isn't a PyXB binding instance it complains.
>>>
>>> That it complains that way is a bug in PyXB, but there's either some
>>> missing schemas you need to incorporate, or the document needs to be fixed.
>>>
>>> Peter
>>>
>>> On 1/27/2010 2:21 PM, Wendell Turner wrote:
>>>
>>>> Hi,
>>>>
>>>> I'm using pyxb to download/compile/generate the bindings for
>>>> the FAA's AIXM schema:
>>>>
>>>> pyxbgen \
>>>> --uri-content-archive-directory downloaded \
>>>> --archive-path '&pyxb/bundles/opengis//:+' \
>>>> --schema-location
>>>> http://wendell-y.rho.net/aixm/SAA_AIXM_5_Schemas/SAA-Feature.xsd \
>>>> -m saa
>>>>
>>>> (and then edit _aixm.py for _Namespace_gml)
>>>>
>>>> However, when trying to read the sample xml file with this
>>>> python program:
>>>> import urllib2
>>>> import saa
>>>> xml =
>>>>
>>>> urllib2.urlopen('http://wendell-y.rho.net/aixm/SAA_AIXM_5_Schemas/sample-Snowbird.xml').read()
>>>> order = saa.CreateFromDocument(xml)
>>>> print order
>>>>
>>>> it gets:
>>>> raise pyxb.UnrecognizedElementError(self.__rootObject)
>>>> pyxb.exceptions_.UnrecognizedElementError:<pyxb.utils.saxdom.Element
>>>> object at 0x9802c0c>
>>>>
>>>> Any suggestions? Did I generate the files correctly? Is
>>>> the supplied sample correct?
>>>>
>>>> Wendell
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> The Planet: dedicated and managed hosting, cloud storage, colocation
>>>> Stay online with enterprise data centers and the best network in the
>>>> business
>>>> Choose flexible plans and management services without long-term contracts
>>>> Personal 24x7 support from experience hosting pros just a phone call away.
>>>> http://p.sf.net/sfu/theplanet-com
>>>> _______________________________________________
>>>> pyxb-users mailing list
>>>> [email protected]
>>>> https://lists.sourceforge.net/lists/listinfo/pyxb-users
>>>>
>>>>
>>>
>>>
>> ------------------------------------------------------------------------------
>> The Planet: dedicated and managed hosting, cloud storage, colocation
>> Stay online with enterprise data centers and the best network in the business
>> Choose flexible plans and management services without long-term contracts
>> Personal 24x7 support from experience hosting pros just a phone call away.
>> http://p.sf.net/sfu/theplanet-com
>> _______________________________________________
>> pyxb-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/pyxb-users
>>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> pyxb-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pyxb-users
>
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
pyxb-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyxb-users