Oracle8i Application Developer's Guide - XML Release 3 (8.1.7) Part Number A86030-01 |
Library | Service | Contents | Index

Personalizing Data Display With XML: Portal-to-Go , 10 of 16

## Converting to XML

A Portal-to-Go Adapter retrieves content from the source. In the example illustrated here, it pulls specific quotes and headlines from a Web page. Then the Adapter converts the content to XML.

### Why Use an Intermediate XML Format?

Why not go straight to the target device format? Two reasons: flexibility and extensibility. To go straight from source to target, you must effectively create an adapter and transformer for each source-target pair. With XML as an intermediate format, you only need one adapter for each source, and one transformer for each device. For example if there are, say two content sources and three target devices

- Source to Target, without XML: You will need six adapter-transformer pairs, namely twelve components altogether

- Source to Target, with XML: You will need only five components altogether, two adapters and three transformers.

### Using the Simple Result DTD

Adapter output must be XML to be generic. The key is to define an XML document type that can represent any data type you might want to display on any device. The document type is defined by a Document Type Definition (DTD). A DTD is a file that provides a grammar for a class of XML documents by describing the elements it can contain.

To create a truly universal intermediate data format, Portal-to-Go uses the Simple Result DTD. Elements in the Simple Result DTD represent the elements of an abstract user interface. These include the following:

- Text items

- Menus

- Forms

- Tables

Figure 7-6 illustrates the Simple Result DTD content model.

#### Figure 7-6 Simple Result DTD Content Model

Following is a portion of SimpleResult.dtd that shows the elements used in our Stock Data example.

    <!--
    Entity:   "GENATTR" contains generic attributes for most elements.
    Attribs:  "name" is the name of the element.
              "title" is the title of the element.
    ...
    -->
    <!ENTITY % GENATTR "
                name    CDATA #IMPLIED
                title   CDATA #IMPLIED
     ...        ">

    <!--
    Element:    "SimpleResult" is the result element.
    Usage:      This element contains the result.
    Children:   "SimpleText" is a text result.
     ...
    -->

    <!ELEMENT   SimpleResult ((SimpleContainer|SimpleText|SimpleMenu|
                SimpleForm|SimpleTable|SimpleImage|SimpleBreak)+)>
    <!ATTLIST   SimpleResult %GENATTR;>
    ...

    <!--
    Element:    "SimpleText" for displaying one or more blocks of text.
    Usage:      Used for plain text.
    Children:   "SimpleTextItem" is a block of text.
    -->

    <!ELEMENT   SimpleText (SimpleTextItem+)>
    <!ATTLIST   SimpleText %GENATTR;>

    <!--
    Element:    "SimpleTextItem" is a block of text
    Usage:      Holds one block of text - normally a single paragraph.
    Children:   "#PCDATA" is the actual text.
    -->

    <!ELEMENT   SimpleTextItem (#PCDATA)>
    <!ATTLIST   SimpleTextItem %GENATTR;>

    ...

    <!--
    Element:    "SimpleForm" for displaying one or more input fields.
    Usage:      As a data-entry form.
    Children:   "SimpleFormItem" for each input field.
    Attribs:    "target" is the link target for this form.
                "section" is the section identifier

***** A special case for the WIDL adapter *****

    -->
    <!ELEMENT    SimpleForm ((SimpleFormItem|SimpleFormSelect)+)>
    <!ATTLIST    SimpleForm %GENATTR;
                 target  CDATA #REQUIRED
                 section CDATA #IMPLIED>
    <!--
    Element:    "SimpleFormItem" is a single input item in a simple form.
    Usage:      For getting input from a user.
    Children:   "#PCDATA" contains pre-filled input from the server.

****** This overrides the default attribute. *******

    Attribs:    "default" provides a default value for optional fields.

***** The default value should only be used if the field is empty.

"mandatory" indicates that the form item is mandatory.

"maxLength" provides a maximum input length.

    -->
    <!ELEMENT   SimpleFormItem (#PCDATA)>
    <!ATTLIST   SimpleFormItem %GENATTR;
                default  CDATA #IMPLIED
                mandatory(yes|no) "no"
                maxLength CDATA #IMPLIED>

    ...

### Adapters Map the Source Content to the DTD Element

Portal-to-Go Adapters map the source content to the appropriate Simple Result element.

- Input bindings specify any data required to complete the request through form <input> tags and variables in the service URL.

- Output bindings are the results returned to the requester. They select only the relevant pieces of HTML for the service and device.

For example, Table 7-1 shows the XML for an input form (text label, input field, and submit button) and results page (ticker symbol, stock price, and headlines) generated by a hypothetical StockData Adapter.

##### Table 7-1 XML for Input and Results Page Generated by StockData Adapter

XML for Input Page | XML Results Page: Quote and Headlines Page
--- | ---
<SimpleResult> <SimpleText> <SimpleTextItem name = "TickerField"> Ticker Symbol: </SimpleTextItem> </SimpleText> <SimpleForm title="Input Form"> <SimpleFormItem name="Ticker"> </SimpleFormItem> <SimpleFormButton name="submitBtn"> Get Quote </SimpleFormButton> </SimpleForm> </SimpleResult> | <SimpleResult> <SimpleText title="Quote Results"> <SimpleTextItem name="Ticker"> ORCL </SimpleTextItem> <SimpleTextItem name="Price"> 90 3/8 </SimpleTextItem> </SimpleText> <SimpleText title="Headlines"> <SimpleTextItem name = "Headline1"> * Oracle surges. </SimpleTextItem> <SimpleTextItem name = "Headline2"> * NASDAQ closes higher. </SimpleTextItem> <SimpleTextItem name = "Headline3"> * US stocks bolt ahead. </SimpleTextItem> </SimpleText> </SimpleResult>

| Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
Library | Service | Contents | Index