APPLICATION DESIGN
Mapping XML tags to a view
In order to produce XML using a view, you have to map the XML tags from your DTD to the columns in the view. Once you have created a view and mapped the XML tags to it, you embed the view into a page. A view embedded into a page maintains the same functionality on the Web as a view in an IBM® Lotus® Notes® client application and allows you to control the size and appearance of the view display. For views displaying XML, the page contains the XML declaration and root element.
Example
The ROI Books application assigns each element and field in a document to a column in the XMLView using a column formula. The column formula for the first child element also contains the open parent tag, and column formula for the last child element contains the close parent tag. For example, the column formula for the first column is:
To map XML to a view
1. Create a view and open it.
2. Select Edit - Properties to open the View Properties box.
3. Click the Advanced tab
4. In For Web Access, select "Treat view contents as HTML." IBM® Lotus® Domino(TM) generates HTML for the contents of a view if this property is not selected. In addition, the contents of a view that is embedded into a page are not visible if this property is not selected.
5. Click "View Selection" on the Objects tab and add a selection formula to define which documents will be included in the view. For example, an application for an online bookstore contains a view for approved orders. Documents are selected for the view using the following formula:
7. Add columns to the view.
8. Click the first column of the view.
9. Enter a column formula in the Script area using the following syntax. "<PARENT><CHILD>"+fieldname+"<\CHILD>" If you have more than one element for any column, add a semicolon (;) at the end of the first column formula and add the column formula for the next element below it. "<PARENT><CHILD>"+fieldname+"<\CHILD>"; "<CHILD>"+fieldname+"<\CHILD>"; "<CHILD>"+fieldname+"<\CHILD>"
Tip Use the following syntax to make a field an attribute of an element. "<CHILD attributeName=\""+fieldname+"\">"+fieldname2+"</CHILD>
10. Click the second column and type a column formula into the Script area using the syntax below. "<CHILD>"+fieldname+"<\CHILD>"
11. Repeat Step 10 for each XML element except the last one.
12. For the last child element, the use the syntax below. "<LASTCHILD>"+fieldname+"<\LASTCHILD></PARENT>"
Embedding a view in a page
1. Open or create a page.
2. Select Design - Page Properties.
3. Click the Page Info tab.
4. In Web Access, select "Treat page contents as HTML," and close the Page properties box.
5. Type an XML declaration above the place where you want the embedded view to display.
6. Place the cursor where you want the embedded view to display.
7. Select Create - Embedded Element - View.
8. (Optional) If you don't want to display the same view in all circumstances, click "Choose a View based on a formula." When you click OK to close the dialog box, write a formula in the Programmer's pane to display the appropriate view.
9. (Optional) Click the embedded view and select Element - View Properties to change the alignment, or style, or to hide the element under certain conditions.
10. Type a close root tag below the view.
To delete an embedded view, click the embedded view in the Work pane and select Edit - Clear.
See Also