In Chapter 4, I mentioned a tool for creating schemas, XML Authority. Why do you need another tool for creating schemas? While XML Authority is great for creating any kind of schema, the BizTalk Editor is optimized to create schemas that define business documents. Also, the schemas created by the BizTalk Editor contain extra information by way of some custom Microsoft and BizTalk namespaces that simplify mapping from one format to another. Using the BizTalk Editor, you can create schemas based on industry standards or you can create specifications unique to your organization.
Let's use the BizTalk Editor to create a schema that can be used with BizTalk Server 2000. Let's create our favorite business document, the purchase order. This will be a standard purchase order schema that we might use to exchange business information with our partners. This example is created with tools from the BizTalk Server 2000 Tech Preview. You should have this or a subsequent version of BizTalk Server 2000 loaded on your system to complete the exercise.
The example you see in Figure 12-1 is simple for the purpose of demonstrating the tools and how they work together. Most documents will be more complex than this—in some cases they will be much more complex. However, the concepts you'll learn here apply to all documents.
Figure 12-1. The BizTalk Editor allows you to create specifications that describe the structure of a business document.
Note that the BizTalk Editor does not use the familiar XML words element and attribute. Instead, it uses records and fields, which are more familiar to typical database programmers. A record is similar to a database record in that it can contain fields. A field is where the data is located. In the BizTalk Editor, a record can contain data and fields. In the declaration area, you must decide to make something an element or an attribute. By default, records are elements, and fields are attributes.
Figure 12-2. Final purchase order structure in the BizTalk Editor.
When you saved the document, the XML schema shown in Listing 12-1 was created. This schema, however, looks different from the basic schemas described in Chapter 4 because the BizTalk Server uses extra information that the basic schema syntax does not provide.
The PurchaseOrder1.xml document created in this example is specified in XML Data Reduced (XDR). However, when the W3C XML Schema Definition (XSD) syntax is finalized, Microsoft will support that syntax as well. Converting from one syntax to the other should be as easy as clicking Save As. You should also be able to use XSLT to make the syntax change.
In Listing 12-1, notice the b: namespace defined in the <Schema> start tag. This namespace contains a set of tags used by various parts of BizTalk Server 2000.
Listing 12-1. Schema created by the BizTalk Editor.
PurchaseOrder1.xml <?xml version="1.0"?> <Schema name="PurchaseOrder" b:root_reference="PurchaseOrder" b:standard="XML" xmlns="urn:schemas-microsoft-com:xml-data" xmlns:d="urn:schemas-microsoft-com:datatypes" xmlns:b="urn:schemas-microsoft-com:BizTalkServer"> <b:SelectionFields/> <ElementType name="PurchaseOrder" content="eltOnly"> <b:RecordInfo/> <AttributeType name="PODate"> <b:FieldInfo/> </AttributeType> <AttributeType name="CustomerNumber"> <b:FieldInfo/> </AttributeType> <attribute type="PODate"/> <attribute type="CustomerNumber"/> <element type="Item"/> </ElementType> <ElementType name="Item" content="textOnly" model="closed"> <b:RecordInfo/> <AttributeType name="Qty" d:type="int"> <b:FieldInfo/> </AttributeType> <AttributeType name="Price" d:type="fixed.14.4"> <b:FieldInfo/> </AttributeType> <attribute type="Qty"/> <attribute type="Price"/> </ElementType> </Schema> |