Configuring XML formatted output > Example: creating an XMLOUT configuration

Example: creating an XMLOUT configuration
In this example, you have the Event configuration in Example 3, and want the StreamServer to generate output according to Example 4.
Example 3
Click to enlarge
 
Example 4
 
<?xml version="1.0"?>
<!DOCTYPE Document [
<!ELEMENT Document (#PCDATA|Element_label|Element_artist)*>
<!ELEMENT Element_label (#PCDATA)>
<!ELEMENT Element_artist (#PCDATA|Element_album|Element_price)*>
<!ELEMENT Element_album (#PCDATA)>
<!ELEMENT Element_price (#PCDATA)>]>
<Document>
  <Element_label>CLASSIC MUSIC</Element_label>
  <Element_artist>Brahms
    <Element_album>Symphonie A</Element_album>
    <Element_price>25</Element_price>
  </Element_artist>
  <Element_label>JAZZ AND BLUES</Element_label>
  <Element_artist>Gillespie
    <Element_album>Jabbadabba</Element_album>
    <Element_price>44</Element_price>
  </Element_artist>
  <Element_label>ROCK AND POP</Element_label>
  <Element_artist>Sting
    <Element_album>Save the jungle</Element_album>
    <Element_price>23</Element_price>
  </Element_artist>
</Document>
 
Configuring the prolog
The figure below illustrates where in the XMLOUT configuration you specify the XML header, and the internal DTD subset used in this example.Click to enlarge
Configure the XML header
1
2
Click to enlarge
Add the internal DTD subset
1
Right-click the Prolog item and select Edit Internal DTD. The Edit Internal DTD dialog box opens.
2
Enter the DTD subset shown below, click Validate and OK. The internal DTD subset is added as an item below the Prolog item, and as a template to the Templates view.
 
<!ELEMENT Document (#PCDATA|Element_label|Element_artist)*>
<!ELEMENT Element_label (#PCDATA)>
<!ELEMENT Element_artist (#PCDATA|Element_album|Element_price)*>
<!ELEMENT Element_album (#PCDATA)>
<!ELEMENT Element_price (#PCDATA)>]>
Configuring the document
You first add the blocks from the Message immediately below the root element. You then use the internal DTD subset as a template to add elements to the XML tree. Finally, when the XML tree is complete, you add fields and static text to the elements.
Add the blocks
1
Drag the Classic block from the Event view, and drop it on the Document node in the Process view. The Classic block is added, within a block container, below the Document node.
2
Do the same with the Jazz and blues and Rock and pop blocks.
Click to enlarge
Add the elements
The steps below describe how to add elements to, and above, the Classic block container. The same steps apply to the other blocks.
1
2
Right-click Element_label in the Template view, drag it to the Classic block container, and release the mouse button. A shortcut menu opens.
3
Select Copy Item above Selection. Element_label is added above the Classic block container.
4
Right-click the Classic block and select Add > Element. A new element is added to the Classic block.
5
Right-click Element_artist in the Template view, drag it to the new element, and release the mouse button. A shortcut menu opens.
6
Select Replace This Item. Element_artist is added to the Classic block.
7
Drag Element_album from the Template view and drop it on Element_artist. Element_album is added as a sub node to Element_artist.
8
Drag Element_price from the Template view and drop it on Element_artist. Element_album is added as a sub node to Element_artist.
Click to enlarge
Add the fields and static text
The steps below describe how to add fields to elements in the Classic block and static text to Element_label above the Classic block container. The same steps also apply to the two other blocks.
1
Right-click Element_label and select Add > Static Text. A Static Text node is added to Element_label.
2
In the Label field for the Static Text node, enter CLASSIC MUSIC.
3
In the Event view, right-click the field Classic_artist, drag it to Element_album, and release the mouse button. A shortcut menu opens.
4
Select Copy Item above Selection. The field is added above Element_album.
5
Drag the field Classic_artist_album from the Event view and drop it on Element_album. The field is added into Element_album.
6
Drag the field Classic_artist_price from the Event view and drop it on Element_price. The field is added into Element_price.
Click to enlarge
OpenText StreamServe 5.6 Updated: 2013-03-01