Home:ALL Converter>Can I add a attribute and a restriction to a xsd type inline?

Can I add a attribute and a restriction to a xsd type inline?

Ask Time:2014-07-01T23:18:54         Author:cp5

Json Formatter

I need to imply a restriction and an attribute on a type. I know it can be done this way

<xs:simpleType name="Name">
    <xs:restriction base="xs:string">
        <xs:minLength value="1"/>
        <xs:maxLength value="15"/>
    </xs:restriction>
</xs:simpleType>

<xs:complexType name="MyCustomeName">
      <xs:simpleContent>
             <xs:extension base="mc:Name">
                    <xs:attribute name="MyTypeOfName" fixed="MCN"/>
             </xs:extension>
      </xs:simpleContent>
</xs:complexType>

Is there a way to do all in one line "inline"

I can add the restriction inline but then I cannot add the attribute as in

<xs:simpleType name="MyCustomName">
<xs:restriction base="xs:string">
        <xs:minLength value="1"/>
        <xs:maxLength value="15"/>
        <xs:attribute name="MyTypeOfName" fixed="MCN"/>          --> This gives an error
    </xs:restriction>
</xs:simpleType>

The reason why I want to do this... is we expose the XSD to a 3rd party and they have issues with the inheritance of the types hence I want to do all inline.

Author:cp5,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/24513826/can-i-add-a-attribute-and-a-restriction-to-a-xsd-type-inline
yy