ZVON > Tutorials > XML Schema and Relax NG Tutorial |
Intro / Search / ZVON |
Index | >> Example 8 / 8 << | Prev | Next | |
The element "A" represents a number (decimal), which must not be in the scientific format (e.g. 1.5E+10 is forbidden - such numbers are not processed by XSLT, for example). We will just use the datatype "decimal", not "float" or "double" (the two latter allow mantissa-exponent notation).
Valid document <A xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >999.99</A> Valid document <A xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >-0.50</A> Invalid document <A xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >1.5e+10</A> Invalid document <A xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >NaN</A> Invalid document <A xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >-INF</A> |
Correct XML Schema (correct_0.xsd) <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > <xsd:element name="A" type="xsd:decimal"/> </xsd:schema> |
We will use the "decimal" datatype from XML Schemas. The element "A" must contain this pattern.
Valid document <A xmlns="">999.99</A> Valid document <A xmlns="">-0.50</A> Invalid document <A xmlns="">1.5e+10</A> Invalid document <A xmlns="">NaN</A> Invalid document <A xmlns="">-INF</A> |
Correct Relax NG schema (correctRelax_0.rng) |