1

What are default values of indicators in XSD Schema when they aren't define directly?

How many times (min and max) and what order in should (or can) I define attributes of foo in XML?

<xs:complexType name="foo">
    <xs:attribute name="name1" type="xs:string"/>
    <xs:attribute name="name2" type="xs:string"/>
</xs:complexType>

P.S. This example is for a real and working project.

kjhughes
  • 106,133
  • 27
  • 181
  • 240
maskalev
  • 360
  • 3
  • 9

1 Answers1

1

In XSD the xsd:attribute/@use attribute determines whether an XML attribute may, must, or must not appear:

  • optional: The attribute may appear but need not. This is the default value.
  • required: The attribute must appear.
  • prohibited: The attribute must not appear.

In XML there can only be at most a single attribute with a given name per element, and the order of attributes is insignificant.

See also

kjhughes
  • 106,133
  • 27
  • 181
  • 240
  • 1
    Thank you for your answer. In my case attribute may appear once (it is analogue of `minOccurs=0, maxOccurs=1` in elements) . [See table 1](https://www.w3.org/TR/xmlschema-0/#OccurrenceConstraints) – maskalev Jul 28 '22 at 18:22