Reusable XSL Stylesheets and Templates
By Tony Marston2005-04-20
The structure of an XML file
2.1 XML file for a LIST screen
The following is a sample of an XML file which was used to create a list screen as shown in
figure 1.
<?xml version="1.0"?>2.2 XML file for a DETAIL screen
<root>
<person>
<person_id size="8" pkey="y">PA</person_id>
<pers_type_id size="6"
control="dropdown"
optionlist="pers_type_id">DOLLY</pers_type_id>
<nat_ins_no size="10">PA</nat_ins_no>
<first_name size="20">Pamela</first_name>
<last_name size="30">Anderson</last_name>
<star_sign control="dropdown"
optionlist="star_sign">Virgo</star_sign>
<pers_type_desc noedit="y">Dolly Bird</pers_type_desc>
</person>
<person>
<person_id size="8" pkey="y">KB</person_id>
......
</person>
<person>
<person_id size="8" pkey="y">FB</person_id>
......
</person>
<person>
<person_id size="8" pkey="y">BB</person_id>
......
</person>
<person>
<person_id size="8" pkey="y">CC</person_id>
......
</person>
<person>
<person_id size="8" pkey="y">WC</person_id>
......
</person>
<person>
<person_id size="8" pkey="y">DD</person_id>
......
</person>
<person>
<person_id size="8" pkey="y">EE</person_id>
......
</person>
<person>
<person_id size="8" pkey="y">SF</person_id>
......
</person>
<person>
<person_id size="8" pkey="y">BG</person_id>
......
</person>
<actbar>
<button id="reset">RESET</button>
<button id="finish">FINISH</button>
</actbar>
<navbar>
<button id="task#person_add.php" context_preselect="N">New</button>
<button id="task#person_upd.php" context_preselect="Y">Update</button>
<button id="task#person_enq.php" context_preselect="Y">Read</button>
<button id="task#person_del.php" context_preselect="Y">Delete</button>
<button id="task#person_search.php" context_preselect="N">Search</button>
</navbar>
<menubar>
<button id="person_list.php" active="y">Person</button>
<button id="pers_type_list.php">Person Type</button>
</menubar>
</root>
The following is a sample of an XML file which was used to create a detail screen as shown in
figure 2.
2.2 XML file for a DETAIL screen
The following is a sample of an XML file which was used to create a detail screen as shown in
figure 2.
<?xml version="1.0"?>This file can be broken down into the following component parts:
<root>
<person>
<person_id size="8" pkey="y">PA</person_id>
<pers_type_id size="6"
control="dropdown"
optionlist="pers_type_id">DOLLY</pers_type_id>
<nat_ins_no size="10">PA</nat_ins_no>
<first_name size="20">Pamela</first_name>
<last_name size="30">Anderson</last_name>
<initials size="6">pa</initials>
<star_sign size="3"
control="dropdown"
optionlist="star_sign">VIR</star_sign>
<email_addr size="50">pam@hollywood.com</email_addr>
<value1 size="6">36</value1>
<value2 size="12">12.34</value1>
<start_date size="12">01 Jul 1980</start_date>
<end_date size="12"></end_date>
</person>
<lookup>
<star_sign>
<star_sign.option id=""></star_sign.option>
<star_sign.option id="ARI">Aries</star_sign.option>
<star_sign.option id="AQU">Aquarius</star_sign.option>
......
<star_sign.option id="TAU">Taurus</star_sign.option>
<star_sign.option id="VIR">Virgo</star_sign.option>
</star_sign>
<pers_type_id>
<pers_type_id.option id=" "></pers_type_id.option>
<pers_type_id.option id="ACTOR">Actor/Artiste</pers_type_id.option>
<pers_type_id.option id="ANON">Anne Oni Mouse</pers_type_id.option>
......
<pers_type_id.option id="PP">Party Pooper</pers_type_id.option>
<pers_type_id.option id="QP">Of Questionable Parentage</pers_type_id.option>
</pers_type_id>
</lookup>
<actbar>
<button id="submit">SUBMIT</button>
<button id="finish">CANCEL</button>
</actbar>
<menubar>
<button id="person_list.php" active="y">Person</button>
<button id="pers_type_list.php">Person Type</button>
</menubar>
<navbar/>
<scrolling>
<scroll id="person" curitem="1" lastitem="10"/>
</scrolling>
<message/>
</root>
<?xml version="1.0"?>The first line contains the XML declaration. The second and last lines identify the root node within the document. Every XML document must contain a root node to encompass all the other nodes. In this example the name of the root node is "root", but it can be anything.
<root>
......
</root>
Here is some data from one of my database tables:
<person>Everything between
<person_id size="8" pkey="y">PA</person_id>
.....
<end_date size="12"></end_date>
</person>
<person>...</person>belongs to the same occurrence (row) from the "person" table. Each element in between belongs to a different field (column) of that table. Note that an element can contain a value and any number of attributes each of which can have its own value. For example, the "person_id" element contains the value "PA" but also attributes for "size" and "pkey".
The next section identifies the options for dropdown lists or radio groups. These are all contained within the node called "lookup".
<lookup>Here there are lists for two fields, "star_sign" and "pers_type_id". Each fields has a number of options which are broken down into ID (supplied as an attribute) and VALUE.
<star_sign>
<star_sign.option id="ARI">Aries</star_sign.option>
......
</star_sign>
<pers_type_id>
<pers_type_id.option id="ACTOR">Actor/Artiste</pers_type_id.option>
......
</pers_type_id>
</lookup>
The last section contains other miscellaneous sets of data:
<actbar>• "actbar" contains a series of buttons for the action bar.
<button id="copy">Copy</button>
......
</actbar>
<menubar>
<button id="person_list.php" active="y">Person</button>
<button id="pers_type_list.php">Person Type</button>
</menubar>
<navbar/>
<scrolling>
<scroll id="person" curitem="1" lastitem="10"/>
</scrolling>
<message/>
• "menubar" contains a series of buttons for the menu bar.
• "navbar" contains a series of buttons for the navigation bar, although in this example there are none.
• "scrolling" contains values for a scroll bar belonging to the "person" entity.
Tutorial Pages:
» Introduction
» The structure of an XML file
» The structure of an XSL file
» Levels of Reusability
» Summary
