次の方法で共有


Base Data Types and Restrictions in the Schema Editor

In the past I had blogged about another item that needed to be manually added to the schema through a text editor.  I have found another case where properties are not exposed in the BizTalk XSD editor.

 

The XSD schema specification defines the ability to restrict the type definitions in section 4.3 of the W3C schema specification.  These constraining facets are implemented in the schema editor by setting the Derived By property to Restriction. 

 

To get this property to show up you need to set the data type of your element using the Base Data Type property instead of setting the data type in the Data Type property.  At this point a new Restriction category will appear in the properties window.  There will be properties that correspond to each of the constraining facets in the XSD specification except for the last two.  These are the totalDigits (4.3.11) and fractionDigits (4.3.12)

 

These last two relate directly to decimal types where totalDigits limits the total number of digits of the entire entry and fractionDigits limits the number of digits appearing to the right of the decimal point.

 

To implement this functionality:

 

1.  Create a schema

2.  Add an element (i.e., price) and set the datatype to xs:decimal through the Base Data Type property

3.  Ensure that the Derived By property is set to Restriction

4.  Save the schema

5.  Open the schema in a text editor

6.  Locate the element you added in step 2

 

<xs:element name="Price">

   <xs:simpleType>

<xs:restriction base="xs:decimal" />

   </xs:simpleType>

</xs:element>

 

7.  Modify the xs:restriction element as follows to add the fractionDigits facet.

 

<xs:element name="Price">

   <xs:simpleType>

<xs:restriction base="xs:decimal"> <xs:fractionDigits value="2"/> </xs:restriction>

   </xs:simpleType>

</xs:element>

 

8.  Save the file and open it back up in Visual Studio using the BizTalk editor

 

Even though the editor does not expose these properties it will still process them when entered by hand.