restriction in XSD schema for an XML line? -
i have line of code
<floatoutput id="2">myvalue</floatoutput>
i want put restriction on "myvalue" should between -50 , 50. have tried many options don't know how use extension , restriction toghether. can answer please?
you need both extension (since have attribute id
) , restriction (since have constraint on content of floatoutput
). 1 approach know of create simple type constraint , extend type attribute. following.
<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema" elementformdefault="qualified"> <xs:simpletype name="floatoutputtype"> <xs:restriction base="xs:integer"> <xs:mininclusive value="-50"/> <xs:maxinclusive value="50"/> </xs:restriction> </xs:simpletype> <xs:element name="floatoutput"> <xs:complextype> <xs:simplecontent> <xs:extension base="floatoutputtype"> <xs:attribute name="id" type="xs:byte" use="required"/> </xs:extension> </xs:simplecontent> </xs:complextype> </xs:element> </xs:schema>
Comments
Post a Comment