XML-схема, точность десятичного значения - PullRequest
9 голосов
/ 30 мая 2011

Это мой xml (не целый):

<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" nillable="true" type="string"/>
        </xsd:sequence>
      </xsd:extension>
    </xsd:complexContent>
  </xsd:complexType>

Например, rekVrednostDdv должен иметь точность 2. Как я могу сказать этому типу, чтобы иметь точность 2.

я стараюсь так:

<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>

но теперь я получаю при использовании http://www.brainbell.com/tutorials/XML/Working_With_Simple_Types.htm

Invalid XML schema: 'Element <xsd:precision> is not allowed under element <xsd:restriction>.'

1 Ответ

17 голосов
/ 30 мая 2011

Создайте новый простой тип, ограничивающий xs:decimal, и используйте <xs:fractionDigits/> для определения точности.Затем обратитесь к этому типу в определении вашего элемента.

<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"/>

Для получения дополнительной информации см. Спецификацию http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...