0

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!!

Shon
  • 690
  • 6
  • 22
  • Sorry, you've done something wrong but there's no way of telling from the information given what it might be. – Michael Kay Nov 15 '14 at 00:26
  • I finally managed to include my code. Somehow I can only include it line by line. Any idea? In the type "state_machine" it cannot see state and in state it cannot see transition. The order in which I define the types doesn't seem to have any effect on this – user3595679 Nov 15 '14 at 10:30

1 Answers1

2

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").

Michael Kay
  • 156,231
  • 11
  • 92
  • 164