The type attribute cannot be present with either simpleType or complexType
Okay, I was struggling with this one for a while and couldn't find any answers on the net and it's one of those things that turn out making you feel stupid.
My xsd schema wouldn't validate. It failed with the error message mentioned on the title of this post: "The type attribute cannot be present with either simpleType or complexType." The relevant part of my schema was:
<xs:complexType name="ct_tuning">
<xs:attribute name="style" type="xs:string" use="required" />
<xs:attribute name="key" type="xs:string" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[a-gA-G]" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
Now what could possibly be wrong with this that???
Well, it turns out the error message is not helpful at all and doesn't make any sense.
The problem with this snippet is that the attribute has already been given a type.If you notice the declaration in bold you'll notice that the attribute named "key" has been declared with type="xs:string". By declaring the simpleType underneath I am declaring its type twice.
Deleting the type="xs:string" from the declaration solved the problem.


19 Comments:
thanks, I had the same issue!
thanks it was helpful!
Thanks! Really useful ;-)
Thanks a bunch!
thanks a lot, saved me a lot of time :)))
Thanks this solved my problem, and I don't feel so stupid now :P
saved my day!!
+1 from me!
Big up yourself!
Thanks!
Article really help. Thank you.
Thank you very much, I was struggling to get any clue on this problem
Simple fix, these are the ones I like most! Thanks :)
thanks!
Bravo!
Excellent post. I was checking continuously this blog and
I'm impressed! Extremely helpful information particularly the last part :) I care for such info much. I was seeking this particular info for a long time. Thank you and good luck.
Review my blog post ... s2000 spoiler
Fantastic web site. Lots of helpful information here.
I'm sending it to some pals ans additionally sharing in delicious. And of course, thank you to your effort!
my homepage :: raspberry ketone diet
Thanks - I know it's 7 years later than everyone elses posts but this just helped me too!
Thank you
thanks!
After searching everywhere in the internet, it is your post helped me to resolve it. Thanks
Thank you so much, your simple explanation of the error made me realize what was wrong with my code after so many hours and searches, :)
Post a Comment
<< Home