XmlSchemaFractionDigitsFacet Class

Specifies a restriction on the number of digits that can be entered for the fraction value of a simpleType element. The value of fractionDigits must be a positive integer. Represents the World Wide Web Consortium (W3C) fractionDigits facet.

Namespace: System.Xml.Schema
Assembly: System.Xml (in system.xml.dll)

public class XmlSchemaFractionDigitsFacet : XmlSchemaNumericFacet
public class XmlSchemaFractionDigitsFacet extends XmlSchemaNumericFacet
public class XmlSchemaFractionDigitsFacet extends XmlSchemaNumericFacet
Not applicable.

The following example shows the use of the XmlSchemaFractionDigitsFacet class.

using System;
using System.Xml;
using System.Xml.Schema;

class XMLSchemaExamples
    public static void Main()

        XmlSchema schema = new XmlSchema();

        // <xs:simpleType name="RatingType">
        XmlSchemaSimpleType RatingType = new XmlSchemaSimpleType();
        RatingType.Name = "RatingType";

        // <xs:restriction base="xs:number">
        XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
        restriction.BaseTypeName = new XmlQualifiedName("decimal", "http://www.w3.org/2001/XMLSchema");

        // <xs:totalDigits value="2"/>
        XmlSchemaTotalDigitsFacet totalDigits = new XmlSchemaTotalDigitsFacet();
        totalDigits.Value = "2";

        // <xs:fractionDigits value="1"/>
        XmlSchemaFractionDigitsFacet fractionDigits = new XmlSchemaFractionDigitsFacet();
        fractionDigits.Value = "1";

        RatingType.Content = restriction;


        // <xs:element name="movie">
        XmlSchemaElement element = new XmlSchemaElement();
        element.Name = "movie";

        // <xs:complexType>
        XmlSchemaComplexType complexType = new XmlSchemaComplexType();

        // <xs:attribute name="rating" type="RatingType"/>
        XmlSchemaAttribute ratingAttribute = new XmlSchemaAttribute();
        ratingAttribute.Name = "rating";
        ratingAttribute.SchemaTypeName = new XmlQualifiedName("RatingType", "");

        element.SchemaType = complexType;


        XmlSchemaSet schemaSet = new XmlSchemaSet();
        schemaSet.ValidationEventHandler += new ValidationEventHandler(ValidationCallbackOne);

        XmlSchema compiledSchema = null;

        foreach (XmlSchema schema1 in schemaSet.Schemas())
            compiledSchema = schema1;

        XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());
        nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
        compiledSchema.Write(Console.Out, nsmgr);

    public static void ValidationCallbackOne(object sender, ValidationEventArgs args)

The following XML file is generated for the preceding code example.

<?xml version="1.0" encoding="IBM437"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

	<xs:simpleType name="RatingType">
		<xs:restriction base="xs:decimal">
		    <xs:totalDigits value="2"/>
			<xs:fractionDigits value="1"/>

	<xs:element name="movie">
			<xs:attribute name="rating" type="RatingType"/>



Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0

XNA Framework

Supported in: 1.0