Home  /  Blog  /  Documentation  /  Code Generator   /  Settings  /  Annotation Attribute

Schema Restrictions

Restrictions are used to define acceptable values for XML or JSon elements or attributes. Restrictions on XML elements are called facets, JSon restrictions are called semantics.

Data Annotations Attribute

In this section we will go over the various settings that interact with the restrictions. Most of these settings let you transport specifications already set in you schemas into you c# classes

Firstly, you can find the settings under the "Output property settings", from there you can open the "DataAnnotationsAttribute" settings, like so : 

Image showing the Data Annotations Attribute settings list

Default Value Attribute

With this setting you can carry over the default value set in you schema, this default value will be applied to the appropriate attributes in the c# classes.

Here's what the restriction looks like in an Xsd and it's generated version :
Xsd : Image showing a default value restriction in xsd 
Generated version : Image showing a default value restriction in the generated code

Fraction Digits Attribute

With this setting you can transport your schema's fraction digits restriction into your generated code, this restriction defines the maximum number of fractional digits (i.e., digits that are after the decimal point). Must be equal to or greater than zero

Here's what this restriction looks like in an xsd and its generated version :
Xsd : Image showing the Xsd version of the fraction Digits Attribute
Generated version : Image showing the fraction digits restriction in code

Max Digits Attribute

With this setting you can carry over your total digit limit restriction from your schema.
This restriction specifies the exact number of digits allowed. It must be greater than zero
Here's an example :
Xsd : Image showing the MaxDigits restriction in an xsd
Generated version : Image showing the MaxDigits code version 

Max and Min Length Attribute

With these settings you can carry over from your schema your a maximum and/or minimum length restrictions on your attributes.
Here's an example of these settings in xsd and their generated versions :
Xsd : Image showing the max and min length attribute settings in an XSD 
Generated version : Image showing the Max and Min length settings in the generated code

Range Attribute

With this setting you can carry over your set range for certain attributes into your generated class.
Here's an example of a range restriction on an xsd attribute and it's generated version : 
Xsd : Image showing a range restriction in an xsd
Generated code : Image showing an xsd attribute's range restriction's generated code version

Regular Expression Attribute

With this setting you can carry over your regular expressions from your schema to your generated code.

This restriction allows the definition of regular expression patterns over the lexical space. The syntax used for these patterns has been borrowed from Perl regular expressions, and has been enhanced to support the Unicode character blocks.

Required Attribute

With this setting you can set wether or not the required attribute is carried over from your schema, this attribute defines some attributes as required, meaning they need to have a value.

For example , in an Xsd the Image showing the required attributes xsd version, minOccurs specification will turn in to this in your c# class : 
  Image showing the generated code's required attribute value

String Length Attribute

With these settings you can carry over from your schema your a maximum and/or minimum length restrictions on your string attributes.

Here's an example of these settings in xsd and their generated versions :
Xsd : Image showing the max and min length attribute settings in an XSD 
Generated version : Image showing the Max and Min length settings in the generated code

Validate Property in Setter

With this setting you can will generate a validator function in the setter 

Terms & privacy

Terms of uses · Privacy policy 

Contact

CodeNGine Technologies, 19 Avenue, de la gare, 34770 Gigean, France. SIRET: 85257252800010, VAT : FR 62852572528
codengine.technologies@xsd2code.com

About the company

CodeNGine Technologies is software company based in the South of France that provides an advanced productivity code generation tool to developers using XML and JSON


Copyright © 2021 CodeNGine Technologies