xml schema, precision of decimal value
This is my xml (not whole):
<xsd:complexType name="xx">
<xsd:complexContent>
<xsd:extension base="tns:xx">
<xsd:sequence>
<xsd:element name="rekVrednostDdv" nillable="true" type="decimal"/>
<xsd:element name="xx" nillable="true" type="dateTime"/>
<xsd:element name="xx" nillable="true" type="decimal"/>
<xsd:element name="xx" nillable="true" type="string"/>
<xsd:element name="xx" nillable="true" type="dateTime"/>
<xsd:element name="xx" nillable="true" type="string"/>
<xsd:element name="xx" nillable="true" type="decimal"/>
<xsd:element name="xx" nillable="true" type="decimal"/>
<xsd:element name="xx" nillable="true" type="string"/>
<xsd:element name="xx" nillable="true" type="string"/>
<xsd:element name="xx" nillable="true" type="decimal"/>
<xsd:element name="xx" nillable="true" type="tns:xx"/>
<xsd:element name="xx" nillable="true" type="dateTime"/>
<xsd:element name="xx" nillable="true" type="string"/>
<xsd:element name="xx" nillable="true" type="string"/>
<xsd:element name="xx" n开发者_如何转开发illable="true" type="string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
For example rekVrednostDdv must have precision 2. How can i tell this type to have precision 2.
i try like this:
<xsd:element name="rekVrednostDdv" nillable="true">
<xsd:simpleType>
<xsd:restriction base="decimal">
<xsd:precision value="6"/>
<xsd:scale value="2"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
but now i get when using http://www.brainbell.com/tutorials/XML/Working_With_Simple_Types.htm
Invalid XML schema: 'Element <xsd:precision> is not allowed under element <xsd:restriction>.'
Create a new simple type that restricts xs:decimal
and use <xs:fractionDigits/>
to define the precision. Then refer to this type in your element definition.
<xs:simpleType name="decimalTwoPrec">
<xs:restriction base="xs:decimal">
<xs:fractionDigits value="2" />
</xs:restriction>
</xs:simpleType>
<xs:element name="rekVrednostDdv" nillable="true" type="decimalTwoPrec"/>
For more info, see the spec http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits
精彩评论