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

Chapter 2 XML Tools Palette : Getting Started with the XML Tools Palette

Getting Started with the XML Tools Palette
 
The XML Tools palette allows you to create and define the following types of XML resources:
DTD — A Document Type Definition (DTD), the schema language specified by the W3C XML 1.0 specification.
Schema — An XML Schema, as defined by the W3C Recommendation (May 2001).
Instance — An XML document conforming to either an XML Schema or DTD. (The Instance resource can also be used to create XML documents that do not use a schema.)
Schemas and DTDs can be used in several places within your integration project. For example, WSDL files (files that describe web services) use schemas to define the input and output messages of a web service. Several TIBCO ActiveMatrix BusinessWorks activities have Input Editor or Output Editor tabs where you can use a reference to a defined schema.
Creating a New Resource
To add a new XML resource to your project, follow these steps:
1.
The XML Tools palette becomes available. If the palette is not available
Choose the Palettes > General > XML Tools menu and make sure XML Tools is checked.
2.
Figure 1 Adding an XML Resource to Your Project
 
Features
When you select a Schema or DTD resource in the project panel, a set of new panels becomes available. You can use these panels to create, validate, and manage the schema resource. Features include:
Getting Started with Schema and DTD Resources
You can access the schema editing panels by using a set of toolbar buttons or the Schema menu. The available tools combine to present a consistent view of your schema. Figure 2 illustrates the editing environment for Schema and DTD resources.
Figure 2 Editing Environment for Schema and DTD Resources
When you begin work on a new XML Schema or DTD, most of your work is performed in the Element/Types Panel, which is used to declare the elements, complex types, and attributes that define document structure and describe data content.
Example: Creating a Schema
For example, to create an element called Book for a schema describing the structure of a book (which may contain elements such as a title, author, chapters, sections, glossary, index, and so on), follow these steps:
1.
Drag a Schema resource from the palette panel to the design panel and double-click it to open it.
2.
If starting a new document, tab to the Element column and replace root with Book.
Names must begin with a letter and may contain numbers, underscores, dashes, and full stops -- typically periods.
3.
Ignore the Derives From column for now as this declaration will not be derived from an existing complex type definition.
4.
Tab to the Content column and select the appropriate content type from the Content Type button. In this example, the content for Book will contain other elements (such as Chapter), so select Elements.
Figure 3 Selecting Content Type
5.
Tab to the Content Model column and type in the content model of the book. A simple content model for Book might look like the one shown below. See Elements/Types Panel and Example: Building a Content Model, for more information on how to build a content model.
Figure 4 Building Content Model
If the content model contains references to sub-elements that are not yet declared, a prompt to create entries for these elements will appear.
6.
Select Create new elements as Locally defined and click Create.
Figure 5 Auto Create Dialog
By default, new elements are declared to have xs:string content, which means they can hold text, but not other elements.
XML Schema elements can be declared locally or globally. Local elements exist within the context of their parent element only. Accordingly, you could have a local element named title that appears within a book element and another local element named title that appears within a mortgage element. Global elements are declared such that they can be referenced within any content model. All global elements must have unique names.
7.
Click Create to create the elements.
8.
Tab to the Attributes column for the element's row and type in attributes for the element. For example, the element Chapter may include attributes that give us more information about a chapter, such as its chapter number and chapter title.
If an attribute is as yet undefined, it is automatically created with data type xs:string. These attributes can be seen and modified in the Attributes Panel. See Attributes Panel for more information.
The figure below illustrates the elements declared in this example.
Figure 6 Elements Declared
The Elements/Type panel always appears beneath the content model diagram. The content model diagram only appears if the Elements/Type panel is selected. The content model diagram provides a graphical overview of your schema.
Figure 7 Content Model Diagram
This serves as a brief introduction into the types of declarations used to build your schema. An overview of the other panels used to build your Instance resources is provided in Table 5.
Getting Started with Instance Resources
When an Instance resource is selected within the project panel, a new set of panels appears, providing an interface for creating and navigating the resource. Features include:
The new panels, in addition to new toolbar buttons and menu options, facilitate the schema-driven creation, editing, and management of data-oriented XML documents, messages, and configuration files. The next diagram illustrates the editing environment for instance resources.
Figure 8 Instance Editing Environment
The interface is optimized for XML documents based on a schema, so associating your document with a schema in your project is typically the first step. For example, to create an instance of an invoice schema:
1.
2.
Select the desired schema from your project and indicate the element to serve as the root element for the document. Most of your work will be performed in the content panel, which consists of a listing of the elements and attributes (tag area) on the left and an area for inserting values for the elements and attributes (edit area) on the right.
Figure 9 Tag Area and Edit Area
3.
4.
This box always contains an empty box with a series of icons below. These icons, when selected, determine the type (element, attribute, and so on) and location (child, sibling, parent) of the node to be entered. If the document is based on a schema, any elements and attributes available based on the schema's content models also appear in the insert drop down box, and can be added with a single mouse click.
 
The factory bar at the bottom of the content panel, provides another option for entering new elements and attributes.
An overview of the other panels you can use to build your Instance resources is provided in Table 5.
Panels
When working with a resource from the XML Tools palette, new panels are provided to help you review and refine the resource. The panels are summarized in the Table 5.
Source Panel (Schema)
Source Panel (Instance)
Errors Panel (Instance)
Note: This panel is referred to as the elements panel when working with DTD resources.
The content panel provides the primary editing area. The panel loads by default when an Instance resource is selected in the project panel. The content panel consists of a left-hand listing of the elements and attributes (tag area) and a right-hand area for inserting values for the elements and attributes (edit area). For more information on the content panel, see Content Panel.
Overview Panel (Schema)
Advanced Panel (Schema)
Common Columns In Tables
Several panels use tables to display the declarations within a schema. Figure 10 illustrates the first two columns that many tables share.
Figure 10 Common Table Columns Used by XML Tools Palette Resources
Toolbar Buttons
When editing or viewing XML Tools resources, additional buttons appear on the toolbar. The toolbar buttons are described in Table 6.
Note: This panel is referred to as the elements panel when working with DTD resources.
Menu Options
When editing resources in the XML Tools palette, menus become available for performing various operations. For Schema and DTD resources, the Schema menu becomes available. For Instance resources, the XML Menu becomes available. The following sections describe the options available for these menus.
Schema menu (Schema and DTD resources)
A Schema menu becomes available when editing a Schema resource. The Schema menu contains two submenus, View and Tools (or Edit).
Table 7 describes the Schema menu.
Note: This panel is referred to as the elements panel when working with DTD resources.
Note: This option is available for Schema resources only.
XML Menu (Instance resources)
An XML menu becomes available when editing an Instance resource. The XML menu contains three submenus: Tools, View, and Presentation.
Table 8 describes the XML menu.
Content Model Diagram
The content model diagram of the elements/types panel graphically displays the content models in a Schema or DTD resource. It presents the relationships between elements (that is, parent elements, child elements, and so on) with diagrams and provides additional information about elements, such as their attributes and occurrence and sequence within a content model. You can use the content model diagram to read, explore, or edit your schemas.
Reading the Content Model Diagram
To view a content model, click the appropriate element in the element/type list (below the diagram). The content model diagram is updated to reflect the currently selected element or type's content model. The content model diagram uses a visual vocabulary to represent complex element content models.
Elements are displayed as objects (in boxes) within the content model diagram. The boxes contain element names, data type indicators, and occurrence indicators. An element’s content model may be composed of text, other elements, text and elements, data, or none of these (as defined in the element definition). The icons used in the content model diagram are illustrated in Figure 11.
Figure 11 Content Model Diagram
If an element’s content model includes other elements (as indicated by the element content icon), the child elements may also be displayed in the content model panel. To view an element’s children, click once on the parent element’s content indicator icon to expand its tree. To collapse the tree and hide the child elements, click on the parent element object again.
Sequence indicator symbols do not appear in the content model diagram, but they are implied. Sequence content models are represented by right-angle brackets, with elements listed in the order that they must appear. Figure 12 illustrates the presentation of an element named sequence.
Figure 12 Diagram for a Sequence
Elements that are separated by the 'or' symbol ('|') in the content model appear to the right of the parent element, after two diagonal branch indicators, in the order they appear in the content model. Figure 13 shows the representation of an element named choices with the content model (choice1 | choice2 | choice3).
Figure 13 Diagram for Choice
Occurrence indicator symbols are used to identify how often an element may or must appear and are shown in the content model diagram. If occurrence indicators apply to a group of elements, the elements are illustrated in the content model diagram as branching off an occurrence indicator symbol. Figure 14 shows a content model similar to that presented in Figure 13, but with the group of choices made optional and repeatable. The multichoice element has the content model (choice1 | choice2 | choice3)*.
Figure 14 Optional and Repeatable Set of Choices
If an occurrence indicator applies only to a single element, it appears appended to the box with the element name. Figure 15 shows a possibilities element whose content model contains all the occurrence indicators: (seq1, choice1?, choice2+, choice3*).
Figure 15 All Occurrence Indicators
Mixed declarations always offer a choice of elements that are both optional and repeatable. These appear as the mixed element shown below in Figure 16. Note that the mixed element may contain both text and elements.
Figure 16 Mixed Content Model
For Schema resources, if a content model is defined as all, a conforming document must contain exactly one of each element specified in the content model (or zero if an element is specified as optional), with the elements occurring in any order. (Elements within an all content model cannot be repeatable.) Figure 17 illustrates the all content model (all1 & all2 & all3), represented with an arc.
Figure 17 All Content Model
Navigating with the Content Model Diagram
The content model diagram also provides navigation to the specifics about a particular element or attribute. To scroll to an element's type definition in the list of elements, right-click on the element while browsing the element in the content model diagram. A context-sensitive menu appears. Click the Go to Element Name option, and the selected element is made active in the list of element definitions.
Editing with the Content Model Diagram
Right-clicking on your content model diagram brings up a menu that allows you to edit your content models. In addition to the navigation features described above, the menu allows you to change the element's occurrence or content.
If you choose to modify the content (content model or data type) for the element, your changes are reflected in the Content and Content Model/Data Type columns of the element/type list below the content model diagram.
Modifying the Display of the Content Model Diagram
To modify the display of the content model panel, right-click the yellow background. A menu appears with the following options.

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