When we specify the name parameter in simpleType, we are getting an error:
"s4s-att-not-allowed: Attribute 'name' cannot appear in element 'simpleType'."
eg:
<xs:simpleType name="lengthValue">
<xs:restriction base="xs:string">
<xs:maxLength value="14"/>
</xs:restriction>
</xs:simpleType>
Is this example is correct? Why are we getting an error like above?
Your fragment may or may not be ok, depending on its context. Since you're getting the given error, it would appear that your context is a local, nested definition, where @name
is not allowed.
xs:simpleType MAY be given a name when used globally. This is ok:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="lengthValue">
<xs:restriction base="xs:string">
<xs:maxLength value="14"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
xs:simpleType may NOT be given a name when used globally. This is NOT ok:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="e">
<xs:simpleType name="lengthValue">
<xs:restriction base="xs:string">
<xs:maxLength value="14"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>
Either
lengthValue
be global, and reference it
using @type
:Here is an example of how to use @name
with xs:simpleType
:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="lengthValue">
<xs:restriction base="xs:string">
<xs:maxLength value="14"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="e" type="lengthValue"/>
</xs:schema>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With