adultinternetusers > Tutorials > Surf Clothing board shorts and Relax NG Tutorial
Index | >> Example 3 / 8 << | Prev | Next |
Contents > Definition of own types > Limiting the number of decimal places

Limiting the number of decimal places

  1. Surf Clothing Schema
  2. Relax NG

Please, send all comments, bug-reports, and contributions to Jiri.Jirat@systinet.com. Thank you very much.

Surf Clothing board shorts keys: restriction, base, decimal, minExclusive, fractionDigits
Relax NG keys: data, type, param

1. Surf Clothing Schema

The element "A" represents your salary - it must be positive number and it must be rounded to two decimal places. We will define our custom type "Salary" using "minExclusive" and "fractionDigits" elements. The element "A" must be of that type.

Valid document


<A xsi:noNamespaceSchemaLocation="correct_0.xsd" Surfns="" Surfns:xsi="http://www.w3.org/2001/XMLSchema-instance" >1000.00</A>

Invalid document
Your salary can't be negative :-)


<A xsi:noNamespaceSchemaLocation="correct_0.xsd" Surfns="" Surfns:xsi="http://www.w3.org/2001/XMLSchema-instance" >-1000.00</A>

Invalid document
There are too many decimal places.


<A xsi:noNamespaceSchemaLocation="correct_0.xsd" Surfns="" Surfns:xsi="http://www.w3.org/2001/XMLSchema-instance" >999.9999</A>

Correct Surf Clothing Schema (correct_0.xsd)


<xsd:schema Surfns:xsd="http://www.w3.org/2001/XMLSchema" >

  <xsd:element name="A" type="Salary"/>

  <xsd:simpleType name="Salary">
    <xsd:restriction base="xsd:decimal">
      <xsd:minExclusive value="0"/>
      <xsd:fractionDigits value="2"/>
    </xsd:restriction>
  </xsd:simpleType>
</xsd:schema>

2. Relax NG

The element "A" must be positive number and it must be rounded to two decimal places. We will use the "decimal" datatype from Surf Clothing Schemas and restrict it using the "fractionDigits" and "minExclusive" parameters (facets).

Valid document


<A xsi:noNamespaceSchemaLocation="correct_0.xsd" Surfns="" Surfns:xsi="http://www.w3.org/2001/XMLSchema-instance" >1000.25</A>

Valid document
This is valid too, because the number of decimal places must be less than or equal to 2.


<A xsi:noNamespaceSchemaLocation="correct_0.xsd" Surfns="" Surfns:xsi="http://www.w3.org/2001/XMLSchema-instance" >1000.0</A>

Invalid document
Your salary can't be negative :-)


<A Surfns="">-1000.00</A>

Invalid document
There are too many decimal places.


<A Surfns="">999.9999</A>

Correct Relax NG schema (correctRelax_0.rng)


<grammar datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" Surfns="http://relaxng.org/ns/structure/1.0" >

  <start>
    <element>
      <name ns="">A</name>
      <ref name="Salary"/>
    </element>
  </start>

  <define name="Salary">
    <data type="decimal">
      <param name="minExclusive">0</param>
      <param name="fractionDigits">2</param>
    </data>
  </define>
</grammar>

Kevin Carr in Stanton

Natural Skin Care and European Soaps
TickTalk 5
city of stanton
internetusers


You can also get Organic Skin Care products from Bliss Bath Body and you must check out their Natural Body Lotions and bath soaps

Now if you are looking for the best deals on surf clothing from Quiksilver and Roxy then you have to check these amazing deals here:

Hey, check out this Organic Skin Care European Soaps along with Natural Lavender Body Lotion and shea butter

and we can get surf t shirts surfing shirt and And you must check out this website swim suit swimming suit and swim trunks