1
votes

I am new in XML, how to handle this tag

<package name="{all}">
<lsf/>
<lsi/>
<lsd/>
</package>

in XSD?

handling this like as:

<xs:element name="package" type="packageType" maxOccurs="unbounded"/>
<xs:complexType name="packageType">
    <xs:sequence>
      <xs:element name="lsf" type="xs:string" />
      <xs:element name="lsi" type="xs:string" />
      <xs:element name="lsd" type="xs:string" />
    </xs:sequence>
  </xs:complexType>

getting exception-

Exception: cvc-complex-type.3.2.2: Attribute 'name' is not allowed to appear in element 'package'.

1

1 Answers

0
votes

The error is pretty self-explanatory - your XML has an attribute on the package element which is not allowed by the schema. You need to declare in the schema that this attribute is allowed, for example:

<xs:element name="package" type="packageType" maxOccurs="unbounded"/>
<xs:complexType name="packageType">
  <xs:sequence>
    <xs:element name="lsf" type="xs:string" />
    <xs:element name="lsi" type="xs:string" />
    <xs:element name="lsd" type="xs:string" />
  </xs:sequence>
  <xs:attribute name="name" type="xs:string" />
</xs:complexType>