Jump to content
Sign in to follow this  
thatsme

Annoying problem with xml schema's attribute

Recommended Posts

Hi, i am new to xml schema. I wrote my schema and when i try to validate it i get such error: file:///usr/local/XSV/xsvlog/tmppWDZw9uploaded:6:2: Invalid per cvc-complex-type.1.3: undeclared attribute {None}:use . Any ideas how to solve it?Here's my code (i highlithed places where i am using "use" attribute):

<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema">		<xs:element name = "Country" type = "countryType"/>		[b]<xs:attribute name ="name" type = "xs:string" use = "required"/>[/b]	<xs:complexType name ="countryType">		<xs:sequence>			<xs:element name = "Commander" type = "xs:string"/>			<xs:element name = "MilitaryExpensesFromGDP" type = "militaryExpensesFromGDPType"/>			<xs:element name = "LandForces" type = "landForcesType"/>			<xs:element name = "AirForces" type = "airForcesType"/>			<xs:element name = "Navy" type = "navyType"/>		</xs:sequence>	</xs:complexType>		<xs:simpleType name = "militaryExpensesFromGDPType">		<xs:restriction base = "xs:float">			<xs:minInclusive value = "0"/>			<xs:maxInclusive value = "100"/>		</xs:restriction>	</xs:simpleType>		<xs:complexType name = "landForcesType">		<xs:sequence>			<xs:element name = "FoundationDate" type = "xs:date"/>			<xs:element name = "MilitaryPersonnel" type = "xs:long"/>			<xs:element name = "Tanks" type = "xs:long"/>			<xs:element name = "FamousBattle" type = "famousBattleType"/>			<xs:element name = "FoughtWar" type = "foughtWarType"/>		</xs:sequence>	</xs:complexType>		<xs:complexType name = "airForcesType">		<xs:sequence>			<xs:element name = "MilitaryPersonnel" type = "xs:long"/>			<xs:element name = "Aircraft" type = "xs:long"/>			<xs:element name = "FamousBattle" type = "famousBattleType"/>			<xs:element name = "FoughtWar" type = "foughtWarType"/>		</xs:sequence>	</xs:complexType>		<xs:complexType name = "navyType">		<xs:sequence>			<xs:element name = "MilitaryPersonnel" type = "xs:long"/>			<xs:element name = "Vessels" type = "xs:long"/>			<xs:element name = "FamousBattle" type = "famousBattleType"/>			<xs:element name = "FoughtWar" type = "foughtWarType"/>		</xs:sequence>	</xs:complexType>		<xs:complexType name = "famousBattleType">		<xs:sequence>			<xs:element name = "FoundationDate" type = "xs:date"/>			<xs:element name = "Enemies" type = "xs:string"/>						[b]<xs:attribute name = "battleTitle" type = "xs:string" use = "required"/>[/b]		</xs:sequence>	</xs:complexType>		<xs:complexType name = "foughtWarType">		<xs:sequence>			<xs:element name = "DateOfBegining" type = "xs:date"/>			<xs:element name = "DateOfEnd" type = "xs:date"/>						[b]<xs:attribute name = "warTitle" type = "xs:string" use = "required"/>[/b]		</xs:sequence>	</xs:complexType></xs:schema>

i would appreciate any help!

Edited by thatsme

Share this post


Link to post
Share on other sites

I think the error message refers to the first time - the global attribute declaration. The use is only defined on per element basis. You can refer to the attribute (with its type and everything) but its use, similarly to the occurance indicators, is done on the local level.

Share this post


Link to post
Share on other sites
I think the error message refers to the first time - the global attribute declaration. The use is only defined on per element basis. You can refer to the attribute (with its type and everything) but its use, similarly to the occurance indicators, is done on the local level.
I get error massage for averyone usage of use attribute. i have also tried to use minOccurence and max Occurencer and got same errprs :)

Share this post


Link to post
Share on other sites

Ah, yes. Didn't noticed that earlier, sorry.Attributes need to be defined outside of sequence indicators, because they can always be present zero or once per element in an unorded fashion.So, replace

			<xs:attribute name = "battleTitle" type = "xs:string" use = "required"/>		</xs:sequence>

with

		</xs:sequence>		<xs:attribute name = "battleTitle" type = "xs:string" use = "required"/>

and do the same for other such occurances.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...