0

I am getting this error whenever I try to add the type for goal as "xs: string". I am not sure what the issue is. If I remove the type the XSD is valid, I need it to have the string type, however, when I add it I get the following error:

cvc-type.3.1.1: Element 'goal' is a simple type, so it cannot have attributes, excepting those whose namespace name is identical to 'http://www.w3.org/2001/XMLSchema-instance' and whose [local name] is one of 'type', 'nil', 'schemaLocation' or 'noNamespaceSchemaLocation'. However, the attribute, 'type' was found.

Is there another way I can still add the type "xs:string"?

   <xs:complexType>
                  <xs:sequence>
                    <xs:element  name="goal" type="xs:string" maxOccurs="unbounded">
                    </xs:element>
                  </xs:sequence>
              

2 Answers2

1

According to the Saxon schema processor, your schema is correct, and the instance is valid. I don't see anything wrong with it at all.

What schema processor are you using?

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

Legit XSD

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="interface">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="pack" type="xs:string" maxOccurs="1" />
        <xs:element name="extension">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="from" type="xs:string" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="import" maxOccurs="unbounded" minOccurs="0" type="xs:string" />
        <xs:element name="method" maxOccurs="unbounded" minOccurs="0" >
          <xs:complexType>
            <xs:sequence>
              <xs:element name="level" type="xs:string" />
              <xs:element name="arguments" maxOccurs="unbounded" minOccurs="0">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="goal" type="xs:string" maxOccurs="unbounded">
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element minOccurs="0" name="throws">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="exception" maxOccurs="unbounded" type="xs:string" />
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="return" type="xs:string" maxOccurs="1" />
            </xs:sequence>
            <xs:attribute name="name" type="xs:string" use="required" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
      <xs:attribute name="id" type="xs:string" use="required" />
    </xs:complexType>
  </xs:element>
</xs:schema>

Valid XML sample

<?xml version="1.0" encoding="utf-8"?>
<interface xsi:noNamespaceSchemaLocation="Joseph.xsd" id="string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <pack>string</pack>
  <extension>
    <from>string</from>
  </extension>
  <import>string</import>
  <import>string</import>
  <import>string</import>
  <method name="string">
    <level>string</level>
    <arguments>
      <goal>string</goal>
      <goal>string</goal>
    </arguments>
    <throws>
      <exception>string</exception>
      <exception>string</exception>
      <exception>string</exception>
      <exception>string</exception>
      <exception>string</exception>
    </throws>
    <return>string</return>
  </method>
</interface>
Yitzhak Khabinsky
  • 18,471
  • 2
  • 15
  • 21