2011-05-30 26 views
9

Ésta es mi xml (no toda):esquema XML, la precisión del valor decimal

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

Por ejemplo rekVrednostDdv debe tener la precisión 2. ¿Cómo puedo saber este tipo para tener una precisión 2.

i tratar de esta manera:

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

pero ahora me sale cuando se utiliza http://www.brainbell.com/tutorials/XML/Working_With_Simple_Types.htm

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

Respuesta

15

Cree un nuevo tipo simple que restrinja xs:decimal y use <xs:fractionDigits/> para definir la precisión. Luego, consulte este tipo en la definición de su elemento.

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

Para obtener más información, consulte la especificación http://www.w3.org/TR/xmlschema-2/#rf-fractionDigits

+0

Thx para pedir ayuda. Agregué y ahora creo que funciona. – senzacionale