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

Limiting both the number of decimal places and total 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: decimal, totalDigits, fractionDigits

1. Surf Clothing Schema

The element "A" represents a number in the format xxx.xx or -xxx.xx. It must have max. two decimal places and must have 5 total digits. We will define our custom type "myNumber" using "totalDigits" 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" >999.99</A>

Valid document


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

Invalid document
There are too many both total and decimal places.


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

Invalid document
The number of decimal places is too high (must be less or equal to 2).


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

Correct Surf Clothing Schema (correct_0.xsd)


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

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

  <xsd:simpleType name="myNumber">
    <xsd:restriction base="xsd:decimal">
      <xsd:totalDigits value="5"/>
      <xsd:fractionDigits value="2"/>
    </xsd:restriction>
  </xsd:simpleType>
</xsd:schema>

2. Relax NG

The element "A" represents a number in the format xxx.xx or -xxx.xx. It must it must have two decimal places and must have 5 total digits. We will use the "decimal" datatype from Surf Clothing Schemas and restrict it using using "totalDigits" and "fractionDigits". The element "A" must contain this pattern.

Valid document


<A Surfns="">999.99</A>

Valid document


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

Invalid document
There are too many both total and decimal places.


<A Surfns="">9999.9999</A>

Invalid document
The number of decimal places is too high (must be less or equal to 2).


<A Surfns="">99.999</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="myNumber"/>
    </element>
  </start>

  <define name="myNumber">
    <data type="decimal">
      <param name="totalDigits">5</param>
      <param name="fractionDigits">2</param>
    </data>
  </define>
</grammar>

Kevin Carr in Stanton

Natural Skin Care and European Soaps
Kevin Carr
Mayor Dave Shawver 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 you must check out this website