XML schema: Oxygen: Cannot resolve ... 'type definition' component

922 views Asked by At

I'm new to xml and I tried to create some complex types. I tried to validate my .xsd in Oxygen but I get "Cannot resolve the name 'state' to a(n) 'type definition' component. 10:70" I really don't get why. This even happens with tutorial code like the last example in http://www.w3schools.com/schema/schema_complex.asp.

I tried to include my code here but it keeps telling me "Your post appears to contain code that is not properly formatted". I tried everything I could find for that to include my code but nothing works. Anyway, like I said it also happens with the example above (surrounded with: <xs:schema version="1.0" xmlns="http://www.w3schools.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> ...here is the example... </xs:schema>

[EDIT]

Ok. After including the code line by line it works. Here it is:

<xs:schema version="1.0" 
           xmlns="http://www.w3schools.com" 
           xmlns:xs="http://www.w3.org/2001/XMLSchema" 
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <xs:complexType name="state_machine">
    <xs:sequence>
      <xs:element name="state" type="state"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="state">
    <xs:sequence>
      <xs:element name="Superclass" type="xs:string"/>
      <xs:element name="transition" type="transition"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="transition">
    <xs:sequence>
      <xs:element name="from" type="xs:string"/>
      <xs:element name="to" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>

Please help!!

1

There are 1 answers

0
Michael Kay On BEST ANSWER

Remove the namespace declaration

xmlns="http://www.w3schools.com"

Defining a default namespace affects the attributes that reference a name (like type="state") but not those that declare a name (like name="state").