Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

XSD Definition For XML

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

I am trying to define a schema (xsd) for the following xml.



The "Team" element has an attribute "desc" of type String.
Within the "Team" element there are further elements ( one to many ) of type "Player".

The "Player" element has a "number" attributes of type String ( 1,2, etc ) and
holds a type String ( Gordan Banks, George Best, etc )


I used the http://xmlgrid.net/xml2xsd.html to get the XSD for the XML :-



I than used http://www.freeformatter.com/xml-validator-xsd.html to effectively validate the xsd and xml.

However, I am encountering the following error :-

Src-element.3: Element 'Player' Has Both A 'type' Attribute And A 'anonymous Type' Child. Only One Of These Is Allowed For An Element.



How can I address this error or is there alternative XSD definition that I can use which adheres to the XML.

Any suggestion would be appreciated. Thank you.

Regards
Pete.



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


You cannot have xs:element having a type attribute defined
and then followed by an xs:complexType or xs:simpleType for that matter, you can only have a construction one kind or another. That's what the error message meant.

The prime way of doing it is to do an extension of a complexType element with simpleContent. Like this.

There may have shortcut and there does, but the idea is there in an elaborated display.
 
Pete Long
Greenhorn
Posts: 19
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi g tsuji,

Thanks for pointing me in the right direction. Very much appreciated

Below is the valid and working xsd for the example xml I provided.



Pete
 
Here. Have a potato. I grew it in my armpit. And from my other armpit, this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic