Re: [pyxb-users] how to create and use an opgengis.filter Literal type?
Brought to you by:
pabigot
From: Peter B. <bi...@ac...> - 2013-10-09 16:49:13
|
On Wed, Oct 9, 2013 at 11:08 AM, Ricardo Filipe Soares Garcia da <ric...@gm...> wrote: > > Hi list > > I built my pxb with the opengis schemas and now I want to work with them. > I am trying to use the Literal() class of the filter module. I can create the object, but I cannot seem to set its value. > I have tried several methods: > > import pyxb.bundles.opengis.filter as ogc_filter > lit = ogc_filter.Literal() > > lit.value = 'hello' # raises ReservedNameError > > lit.content = 'hello' # raises ReservedNameError These are correct diagnostics. > > lit.append('hello') This should have worked. See below. > lit.value() # raises NotSimpleContentError This is a correct diagnostic. > > I am a newcomer to pyxb and haven't managed to make most of the documentation yet so I assum I am using the wrong way here. > > So how would I go about populating my Literal with a value? It seems I have to create some complexTypeContent and then feed it to my object... The schema for http://www.opengis.net/ogc specifies that Literal is an element with type LiteralType, which in turn extends ExpressionType with wildcard element content and also allows mixed content. lit.append(foo) should add foo as content. If foo were a binding instance (i.e., element content allowed by the wildcard) it should have worked. It appears there's a bug and PyXB does not correctly recognize that you are appending mixed (non-element) content here. You can see this by doing the following after append: lit.append('hello') print lit.orderedContent() which shows: [<pyxb.binding.basis.ElementContent object at 0x27bc850>] The element content instance here does not have an associated binding, which is why attempting to interact with it after the append causes problems. For now, to append non-element content do: from pyxb.binding.basis import NonElementContent lit.orderedContent().append(NonElementContent('hello')) I'll enter a trac ticket and fix append so it does the right thing. Peter > Help > > -- > ___________________________ ___ __ > Ricardo Garcia Silva > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk > _______________________________________________ > pyxb-users mailing list > pyx...@li... > https://lists.sourceforge.net/lists/listinfo/pyxb-users > |