Shishupal,
this is a basic XML Schema question, nothing to do with XMLBeans really.
The structure you want is indeed a complex type, so you cannot declare its type
to be xs:string, which is a simple type. Also, you're trying to define the type
in-line within the element declaration (i.e., as an anonymous type), so the
element declaration cannot have a type at the same time.
What you want appears to be simple string content and an attribute, such as:
<xs:element name="test">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
- Wing Yew
________________________________
From: Kumar.Shishupal [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 23, 2008 3:57 PM
To: [email protected]
Subject: elements having attribute and text
Hi,
There might be a simple solution to this; tried searching through archive did
not get any answer.
We have xml structure something like this.
<test name="name1">value1</test>
Here the element has an attribute which makes it's a complex type and text
value, however when I define xsd as ..
<xs:element name="test" type="xs:string">
<xs:complexType>
<xs:attribute name="name" type="xs:string"/>
</xs:complexType>
</xs:element>
xmlBean api gives out following error
...xsd:14:9: error: src-element.3: Illegal to define a nested type when a type
attribute is specified.
If I remove type="xs:string" then it can't have simple string.
Is it possible to define a simple element with and attribute?
Thanks in advance
Shishupal