XML Tutorial/XML Schema/float

Материал из Web эксперт
Перейти к: навигация, поиск

The float data type represents a 32-bit, single-precision Institute of Electrical and Electronics Engineers (IEEE) floating-point number.

<!-- schema -->
<xsd:element name="charge">
  <xsd:simpleType>
   <xsd:restriction base="xsd:float">
    <xsd:minExclusive value="1.00"/>
    <xsd:maxExlusive value="100.00"/>
   </xsd:restriction>
  </xsd:simpleType>
</xsd:element>
<!-- instance document -->
<charge>19.99</charge>


Use float data type

File: Schema.xml
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.wbex.ru" xmlns="http://www.wbex.ru"
  elementFormDefault="qualified">
  <xs:element name="population" type="xs:float" />
</xs:schema>

File: Data.xml
<?xml version="1.0"?>
<population xmlns="http://www.wbex.ru">34.2</population>