I'm having problems creating complex type that is required to be non-(null|blank) and have a 'qualifier' attribute that is also non-(null|blank). This is what I have so far.
<xsd:complexType name="PRODUCT">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="Qualifier" type="xsd:string" use="required" />
</xsd:extension>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
</xsd:restriction>
</xsd:simpleContent>
</xsd:complexType>
It is impossible to have both
extension
andrestriction
in the same type definition. Define a simple type with the restriction, and then extend this custom type. You can use this simple type both for the element and attribute definition.Please note that XML (and, by extension, if you forgive the pun, XML Schema) is case-sensitive. "qualifier" and "Qualifier" are not the same attribute names.
The following XML document will be valid against the schema above:
while documents like
or
will be invalid.