Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved

Chapter 2 XML Tools Palette : XML Instance Exercise

XML Instance Exercise
To help you become familiar with the editing facilities available when working with Instance resources, we have included this step-by-step exercise. The exercise walks you through the creation of an XML instance document, introducing you to the fundamental features of the editing environment. This exercise should take around 15 minutes to complete.
When working with Instance resources, TIBCO Designer operates as a “schema-aware” editor, which means you can validate your XML documents against a DTD or XML Schema as you build them or after they have been created. In our example, we will create an XML document using the price list schema created in the first XML Schema Exercise (see XML Schema Exercises) as a template. The example will also demonstrate the customizable view you can create of the XML document as well as all documents you later create based on the same schema.
Getting Started
1.
2.
3.
4.
5.
6.
7.
Figure 94 Content Panel
 
Building Your Document
The factory bar, illustrated in Figure 94 above, is one way you can insert additional elements or attributes into your document; you can also double-click on an element within the tag area and use the drop-down window that appears to add components to your document. Figure 95 depicts the document-building options.
Figure 95 Document-Building Options
 
1.
To add the name attribute to the manufacturer element, click on manufacturer within the tag area. Once manufacturer is selected, name becomes an option on the factory bar. Click once on name to add it to the document.
Figure 96 Factory Bar
2.
Select promotion within the tag area, and use the factory bar to add the start.date and end.date attributes.
Figure 97 Adding Element
S
Customizing and Populating Your Document
Now we will customize the view we have of this document to make it more approachable and facilitate the entry of data within it. The view we create will be preserved and associated with the schema used to create this document. This means that as long as needed, every new XML document created using the same schema will be presented the same way automatically. (Multiple presentations may be associated with a given schema, providing multiple display options for an instance document.)
1.
If you right-click on the element manufacturer, a menu of options will appear. Select Element “manufacturer” > Color > Green to highlight the element with a green background.
You will notice that the manufacturer element has now been highlighted in green. This makes finding the element to add data or content easy and identifies each occurrence of the element.
2.
Use the same procedure to highlight the product element in yellow and the promotion element in blue.
Figure 98 Highlight the Product Element
S
3.
Now you can promote the child elements as well as the attributes of manufacturer to make the entry of data easier and the document view more manageable.
Promotion is especially helpful when working with data-centric documents containing a lot of mark-up but little content. To do this, move your pointer over the small blue icon next to the attribute name and drag the attribute to the right into the edit area and move it up one row. There will be a small black indicator that will demonstrate where the attribute is going to be repositioned. Release the attribute next to its associated element manufacturer.
4.
Now drag the element date.issued up to the right of the attribute name, on the same level of manufacturer.
Figure 99 Promoting the Elements
 
5.
Promote sku, product.name, and price up to their parent, product.
6.
Finally, drag start.date, end.date, and price to the same level of their parent, promotion.
Figure 100 Promoting the Elements
7.
To illustrate the entry of data, click to the right of the name attribute and enter a value that conforms to the data type, in this case a string.
8.
Prices should be entered as decimal data. As you enter data corresponding to the required data type, the errors reported in the errors panel will disappear.
Figure 101 Enter Price
9.
To add another product to the price list, highlight product in the tag area and then select product from the factory bar. Notice that the new product tag retains the formatting already specified for its element.
Figure 102 Add Another Product
You have completed the example for customizing and building an XML document from a schema. One important feature is that once you create a document based on a schema, each additional document you make that uses the same schema will have the same view. To test this, save your document (using the Apply button of the configuration panel) and then start a new document and set the same pricelist schema to start it. Immediately upon setting the schema, the view of the new document will be the same as this document. Use the Presentation menu (XML > Presentation) to return to the default view or to save a new view of the document.

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved