10.5. Choice Editor (XML) 10.5.1. Choice Editor (XML) Within an XML Document model, a choice compositor defines all possible document data structures (sometimes called fragments) that can appear at that location in an XML instance document. When the JBoss Data Virtualization Server populates an XML instance document at runtime based upon your virtual XML document, it will choose the first fragment that matches the criteria you specify within the Choice Editor. To view the choice editor, right-click on the choice node in the mapping diagram's XML Document tree view and click Edit from the right-click pop up menu. Figure 10.27. Opening The Choice Editor Figure 10.28. The Choice Editor The table on this panel displays fragment options for the choice, each represented by the top node of the document fragment. The Summary tab, shown below, displays an SQL like version of the current choice criteria. Figure 10.29. Choice Criteria Summary Using the Choice Editor You can address each choice option by performing one of the following: Specify a criteria statement for the JBoss Data Virtualization Server to apply in order to determine which elements or elements to insert into the result document. Exclude or include the option's fragment from the document. Set the criteria test order for elements. Set a default action that occurs if none of the criteria you set is met. 10.5.2. Excluding Fragments The XML Schema upon which you based the XML Document model determines the nature of the options available to the choice. A schema you share with other, external sources (such as business partners) might include information that you do not want to include within XML files. For example, Sample Financial Services shares an XML schema with its partners Example Mutual Insurance, Illustrative Brokerage, and FinancialPartners.com. The partners created the schema broadly, to cover all possibilities for information they might need to interchange. As such, the customer information XML document might include a choice compositor based on a list of all products all companies offer. However, Sample Financial does not offer a credit card; so it could exclude those elements from the XML documents its JBoss Data Virtualization Server creates since it will never have credit card information for an XML document. The table on the Choice Editor contains the Includes column. By default, all elements specified by the schema are included. You can click to remove the check mark beside any element you do not want to include within your XML documents generated by this virtual XML document metadata model. By removing the check mark, you are not removing the element from the XML Document model; you are merely telling the JBoss Data Virtualization Server that it will never use this element as part of the choice. You cannot edit criteria for excluded elements. However, if you exclude an option for which you have established a criteria, Teiid Designer will retain the criteria if you want to include the option in the future. 10.5.3. Editing Choice Criteria To edit the criteria for a choice element: In the table on the Choice Editor panel, select the element you want to edit.. Click Edit Criteria button to launch the Criteria Builder dialog. Use the Criteria Builder to create the conditions for which the JBoss Data Virtualization Server will test to determine whether to choose this option in the XML instance document. Click OK . The criteria you set displays both in the table and in the summary tab. You must set a criterion for each option in your document unless you have selected to exclude that option or specify that option will be the default option. 10.5.4. Setting Choice Element Order To edit the criteria for a choice element: The JBoss Data Virtualization Server evaluates the choice criteria in the order in which they appear, and when one choice criteria is met, the JBoss Data Virtualization Server populates the XML instance document with that option. The JBoss Data Virtualization Server might not test all criteria for all options, so their order matters a great deal. Therefore, the order in which your options appear within the choice criteria often determines what information appears ultimately in your XML instance documents. You can reorder the option list within the choice to set the order in which the JBoss Data Virtualization Server tests the criteria. To set this order, select an element in the table and use the or button to move it into a new position in the table. The new order displays both in the table and in the Choice Criteria box and reorders the XML document as well. 10.5.5. Setting a Default Choice Action The default action represents the course the JBoss Data Virtualization Server takes if none of the criteria you set evaluates to true. You can set this default using the combo box available in the Choice Editor's toolbar to: Any of the options within the table except those you have excluded from the document. THROW to throw a JBoss Data Virtualization Server exception. RECORD to record the JBoss Data Virtualization Server exception. DISCARD to place no element within the XML instance document. Note You must set a default action for your choice criteria.

Commands: