Defining a complexType in xsd: Src-resolve: Cannot Resolve The Name 'variable1' To A(n) 'type Definition' Component

static picture static · Sep 15, 2012 · Viewed 9.4k times · Source

I get an error:

Src-resolve: Cannot Resolve The Name 'variable1' To A(n) 'type Definition' Component.

by validating the following scheme:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

               ...

                            <xs:element name="variables" maxOccurs="1">
                            <xs:complexType>
                                <xs:annotation>
                                    <xs:documentation>AWK external variables (from bash)</xs:documentation>
                                </xs:annotation>
                                <xs:sequence>
                                    <xs:element name="variable" type="variable" minOccurs="1"/>
                                    <xs:complexType name="variable">
                                        <xs:sequence>
                                            <xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1"/>
                                            <xs:element name="value" type="xs:string" minOccurs="1" maxOccurs="1"/>
                                        </xs:sequence>
                                    </xs:complexType>
                                </xs:sequence>
                            </xs:complexType>
                        </xs:element>



             ...

</xs:schema>

What could be wrong? I want define a global complexType "variable" as the "BookType" described here: http://www.ibm.com/developerworks/library/xml-schema/#list9

Answer

Petru Gardea picture Petru Gardea · Sep 15, 2012

Simply move the content of the element starting <xs:complexType name="variable"> as a child of the xs:schema.

A type is one of those things in XML Schema that cannot be named unless its parent is the xs:schema (or a redefine, but that's another thing).