Re: [pyxb-users] creating an opengis.oseo.DeliveryInformationType element
Brought to you by:
pabigot
From: Peter B. <bi...@ac...> - 2014-02-21 21:14:08
|
You can't create an element for which there isn't a schema, except that PyXB will treat DOM elements as wildcards which can be appended to an xsd.anyType() instance instead of appending instances of an element derived from some other schema. If you use the oseo bindings to parse that example document into a Python instance, you'll see the raw DOM instances as the content of the values element. Normally you'd have schema for a namespace that is appropriate for your application, and use those in something like: pd.values = xsd.anyType() pd.values.append(ds.processingLevel('1B')) pd.values.append(ds.productType('ASA_IMS_1P')) pd.values.append(ds.qualityOfService('STANDARD')) AFAICT there is no schema for those samples ( http://www.opengis.net/oseo/1.0/dataset is not the same namespace as oseo uses), so there is no ds module to use this way. While it's probably possible to create the DOM content manually, it's not easy to do it in a way that has the internal hints that lets PyXB generate documents with the necessary namespace declarations (I just spent an hour on it and am giving it up as not worth the time; sorry). Peter On Fri, Feb 21, 2014 at 8:57 AM, Ricardo Filipe Soares Garcia da < ric...@gm...> wrote: > Hi again > > >> >> >> http://schemas.opengis.net/SCHEMAS_OPENGIS_NET.tgz includes, along with >> the schemas, some sample documents for oseo. Those might help in figuring >> out what should be assigned to the values. >> >> > Yes, I am trying to reproduce the following snippet, which comes from a > sample document of the oseo standard (GetStatusResponse.xml): > > <option> > <ParameterData> > <encoding>XMLEncoding</encoding> > <values xmlns:ns="http://www.opengis.net/oseo/1.0/dataset"> > <ns:processingLevel>1B</ns:processingLevel> > <ns:productType>ASA_IMS_1P</ns:productType> > <ns:qualityOfService>STANDARD</ns:qualityOfService> > </values> > </ParameterData> > </option> > > How can I create the processingLevel element? It seems I must create a > complexType element with its own name. Sadly, I cannot figure out how to do > it ;) > > These elements are not defined in the oseo schema, so I am not sure how > I'd go about creating them. I've tried several combinations involving > pyxb.binding.basis.element, but after trying so many different stuff I am > not so sure of what I am doing at this point. > > Thanks a lot for your (continued) help. > > > Peter >> >> >> On Thu, Feb 20, 2014 at 6:34 PM, Ricardo Filipe Soares Garcia da < >> ric...@gm...> wrote: >> >>> Hi Peter >>> >>> I got it working now, thanks for your help! >>> >>> Now I am failing at building an oseo.ParameterData. I can't seem to >>> create the 'values' element, which should be an AnyType element. I am still >>> a beginner with these things so maybe this is something obvious... >>> >>> By the way, I am following the oseo specification section 7.3.9 >>> ParameterData, Figure 7-12, if it is relevant >>> >>> # Python code >>> import pyxb >>> import pyxb.bundles.opengis.oseo as oseo >>> pd = oseo.ParameterData() >>> pd.encoding = 'TextEncoding' >>> pd.values = pyxb.BIND() >>> pd.values.name = 'test option' >>> pd.values = 'test value' >>> pd.toxml() >>> >>> ...AttributeError: 'str' object has no attribute 'toDOM' >>> >>> Am I adding the 'name' attribute correctly? How can I set the 'values' >>> element? >>> >>> Thanks in advance >>> >>> >>> >>> On Thu, Feb 20, 2014 at 3:12 PM, Peter Bigot <bi...@ac...> wrote: >>> >>>> You need to create the instance using an element, not the underlying >>>> type, so PyXB can tell what string to put in the start and end tags of the >>>> XML. >>>> >>>> See >>>> https://sourceforge.net/p/pyxb/discussion/956708/thread/1204a2fa/#e804and any or all of these three threads for more information: >>>> >>>> https://sourceforge.net/p/pyxb/discussion/956708/thread/1204a2fa/ >>>> https://sourceforge.net/p/pyxb/discussion/956708/thread/fe705025/ >>>> https://sourceforge.net/p/pyxb/discussion/956708/thread/5d5e0320/ >>>> >>>> Peter >>>> >>>> >>>> >>>> On Thu, Feb 20, 2014 at 9:05 AM, Ricardo Filipe Soares Garcia da < >>>> ric...@gm...> wrote: >>>> >>>>> Hi list >>>>> >>>>> I am trying to use a pyxb.bundles.opengis.oseo.DeliveryInformationType >>>>> but keep getting an error. I want to create the element, fill it with >>>>> values and then get its XML representation. >>>>> >>>>> # Python code >>>>> import pyxb.bundles.opengis.oseo as oseo >>>>> dit = oseo.DeliveryInformationType() >>>>> dit.mailAddress = oseo.DeliveryAddressType(firstName='Ricardo') >>>>> dit.toxml() >>>>> >>>>> UnboundElementError: Instance of type { >>>>> http://www.opengis.net/oseo/1.0}DeliveryInformationType has no bound >>>>> element for start tag >>>>> >>>>> I'm using pyxb version 1.2.3 downloaded from pypi >>>>> >>>>> How can I overcome this issue? >>>>> >>>>> Thanks in advance >>>>> >>>>> -- >>>>> ___________________________ ___ __ >>>>> Ricardo Garcia Silva >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> Managing the Performance of Cloud-Based Applications >>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. >>>>> Read the Whitepaper. >>>>> >>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk >>>>> _______________________________________________ >>>>> pyxb-users mailing list >>>>> pyx...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/pyxb-users >>>>> >>>>> >>>> >>> >>> >>> -- >>> ___________________________ ___ __ >>> Ricardo Garcia Silva >>> >>> >>> ------------------------------------------------------------------------------ >>> Managing the Performance of Cloud-Based Applications >>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. >>> Read the Whitepaper. >>> >>> http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk >>> _______________________________________________ >>> pyxb-users mailing list >>> pyx...@li... >>> https://lists.sourceforge.net/lists/listinfo/pyxb-users >>> >>> >> > > > -- > ___________________________ ___ __ > Ricardo Garcia Silva > > > ------------------------------------------------------------------------------ > Managing the Performance of Cloud-Based Applications > Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. > Read the Whitepaper. > > http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk > _______________________________________________ > pyxb-users mailing list > pyx...@li... > https://lists.sourceforge.net/lists/listinfo/pyxb-users > > |