Thanks for the quick answer, I'll file a ticket later today.

Best,
Dim



________________________________
 From: Peter Bigot <big...@acm.org>
To: Dimster <dimsterd...@yahoo.com> 
Cc: "pyxb-users@lists.sourceforge.net" <pyxb-users@lists.sourceforge.net> 
Sent: Wednesday, 28 March 2012, 16:12
Subject: Re: [pyxb-users] Add text to mixed xml elements
 
On Wed, Mar 28, 2012 at 1:51 PM, Dimster <dimsterd...@yahoo.com> wrote:
> Hi,
>
> Is there a way to add text to an element of type MIXED?
>
> Consider:
>
>   <xs:complexType name="IntervalValueType" mixed="true">
>     <xs:sequence>
>       <xs:element name="MinValue" minOccurs="0" maxOccurs="1"
> type="xs:string" />
>       <xs:element name="MaxValue" minOccurs="0" maxOccurs="1"
> type="xs:string" />
>     </xs:sequence>
>   </xs:complexType>
>
> and the corresponding pyxb binding:
>
> # Complex type IntervalValueType with content type MIXED
> class IntervalValueType (pyxb.binding.basis.complexTypeDefinition)
>
> Using the above class, how can I output
>
> <value>5</value>, where value is of IntervalValueType?
>
> I have tried all combinations of constructors and appends but I wasn't able
> to achieve that - I always get
> <value><MinValue>5</MinValue></value>

PyXB's support for mixed content is pretty weak, mostly because
there's no canonical representation (i.e., no way to reconstruct the
proper order of elements and non-element content when converting back
to XML in accordance with the content model).  What's supposed to work
is something like:

x = ff.IntervalValue(MinValue="one")
x.append("text", maybe_element=False)
print x.content()
print x.toxml()

but although that puts "text" in as mixed content, it doesn't come out again.

PyXB is supposed to spit out all the non-element content in a block
after the element content, but in fact it doesn't (see
pyxb.binding.basis.complexTypeDefinition._toDOM_csc where it walks
over the mixed content doing nothing).

Please file a ticket at https://sourceforge.net/apps/trac/pyxb/ and
I'll look at this.

Peter

> Thanks,
> Dim
>
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> pyxb-users mailing list
> pyxb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyxb-users
>
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
pyxb-users mailing list
pyxb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyxb-users

Reply via email to