I assume "example" below is an instance of a complex type you didn't
provide.  I think the issue is that there is only one Field in whatever
that containing element is, while there are multiple Value elements in a
single Field element.

       xmls = '<Field Name="status"><Value ReferenceValue="Some Ref
Value">Open</Value></Field>'
       instance = CreateFromDocument(xmls)
       print instance.toxml('utf-8')
       print instance.Name
       print 'Field %s has %u values' % (instance.Name, len(instance.Value))
       for v in instance.Value:
           print 'Value type %s is %s' % (v.ReferenceValue, v.value())

produces:

<?xml version="1.0" encoding="utf-8"?><Field Name="status"><Value
ReferenceValue="Some Ref Value">Open</Value></Field>
status
Field status has 1 values
Value type Some Ref Value is Open

Peter

On Fri, Jan 4, 2013 at 1:12 PM, Aaron Storm <aaron_st...@yahoo.com> wrote:

> Issue with Complex type with content type SIMPLE
>
>
> I am having problems trying to access the content of an element. Any idea
> what I should do?
>
>
> >> example.Field[0].Name #works
> status
>
> >> example.Field[0].Value #doesn't work
> >> example.Field[0].Value.value #doesn't work
> >> example.Field[0].Value.ReferenceValue #doesn't work
>
>
> Here is the snippet of the xml and xsd:
>
> xml:
>   <Field Name="status">
>     <Value ReferenceValue="Some Ref Value">Open</Value>
>   </Field>
>
> xsd>:
>   <xs:element name="Field" maxOccurs="unbounded">
>     <xs:annotation>
>       <xs:documentation>A single field.</xs:documentation>
>     </xs:annotation>
>     <xs:complexType>
>       <xs:sequence>
>         <xs:element name="Value" minOccurs="0" maxOccurs="unbounded">
>           <xs:annotation>
>             <xs:documentation>The current value of the field in this
> entity instance. Multi-value fields contain multi-value elements. Reference
> fields contain the ReferenceValue attribute.</xs:documentation>
>           </xs:annotation>
>           <xs:complexType>
>             <xs:simpleContent>
>               <xs:extension base="xs:string">
>                 <xs:attribute name="ReferenceValue" type="xs:string"
> use="optional"/>
>               </xs:extension>
>             </xs:simpleContent>
>           </xs:complexType>
>         </xs:element>
>       </xs:sequence>
>       <xs:attribute name="Name" type="xs:string" use="required">
>         <xs:annotation>
>           <xs:documentation>The field name.</xs:documentation>
>         </xs:annotation>
>       </xs:attribute>
>     </xs:complexType>
>   </xs:element>
>
> Generated class:
>
> # Complex type [anonymous] with content type SIMPLE
> class CTD_ANON_3 (pyxb.binding.basis.complexTypeDefinition):
>     """The current value of the field in this entity instance. Multi-value
> fields contain multi-value elements. Reference fields contain the
> ReferenceValue attribute."""
>     _TypeDefinition = pyxb.binding.datatypes.string
>     _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_SIMPLE
>     _Abstract = False
>     _ExpandedName = None
>     _XSDLocation =
> pyxb.utils.utility.Location('C:\\Temp\\rest\\xsd\\Entity.xsd', 25, 11)
>     # Base type is pyxb.binding.datatypes.string
>
>     # Attribute ReferenceValue uses Python identifier ReferenceValue
>     __ReferenceValue =
> pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None,
> u'ReferenceValue'), 'ReferenceValue',
> '__AbsentNamespace0_CTD_ANON_3_ReferenceValue',
> pyxb.binding.datatypes.string)
>     __ReferenceValue._DeclarationLocation =
> pyxb.utils.utility.Location('C:\\Temp\\rest\\xsd\\Entity.xsd', 28, 14)
>     __ReferenceValue._UseLocation =
> pyxb.utils.utility.Location('C:\\Temp\\rest\\xsd\\Entity.xsd', 28, 14)
>
>     ReferenceValue = property(__ReferenceValue.value,
> __ReferenceValue.set, None, None)
>
>
>     _ElementMap = {
>
>     }
>     _AttributeMap = {
>         __ReferenceValue.name() : __ReferenceValue
>     }
>
>
> Regards,
>
>
> ------------------------------------------------------------------------------
> Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
> much more. Get web development skills now with LearnDevNow -
> 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
> SALE $99.99 this month only -- learn more at:
> http://p.sf.net/sfu/learnmore_122812
> _______________________________________________
> pyxb-users mailing list
> pyxb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyxb-users
>
>
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122912
_______________________________________________
pyxb-users mailing list
pyxb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyxb-users

Reply via email to