• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XSD Validation Failed: Element has both a 'type' attribute and a 'anonymous type' child.

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

When i validate the XSD file it gives the following error.

src-element.3: Element 'Account' has both a 'type' attribute and a 'anonymous type' child. Only one of these is allowed for an element.




Any help on this will be appreciated

thanks
 
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a common mistake. Either an element (xs:element) has its type defined locally (embedded within it) which would be necessarily anonymous (a type without a name), or it has a named type which would be necessarily named and of global scope.

Hence either you write

Then directly under xsd:scheme, define the type.

OR with your present structure, take out the attribute type="account:Account" in the xs:element of name="Account" there.

That's all.
 
muhammad sabrin
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

When i give the name attribute for the complexType it gives the error "s4s-att-not-allowed: Attribute 'name' cannot appear in element 'complexType'."
 
g tsuji
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you observed this when you give name to complexType in question?

directly under xsd:scheme, define the type

 
muhammad sabrin
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

Please find the bold item for the complexType name which gives the error s4s-att-not-allowed: Attribute 'name' cannot appear in element 'complexType'.

<xsd:element name="AccountDetailsResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Account" type="account:Account">
<xsd:complexType name="Account">
<xsd:sequence>
<xsd:element name="ID">
<xsd:complexType>
<xsd:sequence>
<xsd:element type="xsd:string" name="NAME"/>
<xsd:element type="xsd:string" name="PHONE"/>
<xsd:element type="xsd:string" name="CATEGORY"/>
<xsd:element type="xsd:int" name="LASTMODIFIED"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

Please help with the changes on the posted xml to avoid mistakes which will be much appreciated.

Thanks
 
g tsuji
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read the help above _very_ carefully !
 
muhammad sabrin
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi tsuji,

Thanks and appreciate your help on this !! i'm a newbie for the xsd.

if i follow the above approach of xsd with complexType name the output is





But i need to do something like this





i'm using JAXB to generate the class based on the xsd definition for the soap (Spring + SOAP)


I'm using the below code to set on the response for the XSD



response.setAccountDetails(account); // requires the attribute <xsd:element name="Account" type="account:Account"> to set it in Account class objects


Appreciate your help.


Thanks
 
g tsuji
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

if i follow the above approach of xsd with complexType name the output is


Note really. It has an addition child element Account under AccountDetailsResponse, that is what originally your schema seems to suggest. If you don't need that at all, you do this and it will be the xml structure you said you need to have.

I won't comment on jaxb. If you are not at ease on xsd already, I see no reason to work on jaxb.
 
reply
    Bookmark Topic Watch Topic
  • New Topic