You ask: "Is my syntax correct [in example 1], or should I write [example 2]?"
None.
In the first example, you use the unqulared maxLength attribute on an xs: element element. (The minOccurs attribute may or may not be allowed, depending on the context, as Peter Gardea has already pointed out, it is not legal for declarations of top-level elements.) Editors who do not create errors on this do not do the full job of checking the conformity of the XSD scheme for schemes (not to mention the full limitations of XSD). If you need reliable verification of XSD, Xerces, Saxon, MSV schema documents or some other appropriate implementation of XSD, your friend.
In the second example, minOccurs ceases to be an element declaration attribute (which may be in some contexts) and becomes an element (no, not so) inside xs: constraint (no, incorrect). The maxLength fragment is correctly represented as a child of the xs: restriction element, but the element in your example is poorly formed; seems to be trying to use the element type name as the attribute name. If you remove the erroneous minOccurs element and correct the invalid maxLength element, the rest is the syntactically correct top-level element declaration for Name:
<xs:element name="name"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:maxLength value = "125"/> </xs:restriction> </xs:simpleType> </xs:element>
source share