• Ingen resultater fundet

Beginning on the GUI Specification

In document XML Specification of GUI (Sider 93-97)

1.2 User Manual

1.2.1 Beginning on the GUI Specification

The GUI specification has to start as shown below:

<?xml version="1.0"?>

<?xml-stylesheet type="text/xsl" href="gui.xsl" ?>

<gui xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:noNamespaceSchemaLocation="gui.xsd">

……

</gui>

“<? xml“ is required. It means now it starts a processing instruction, and declares this is to be an XML document.

“version” is required, it identifies the version of XML specification in use. Version 1.0 is the only current version so the value must be 1.0.

“<?xml-stylesheet…>” is required, it specifies which XSL document should refer to.

<xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:noNamespaceSchemaLocation="gui.xsd"> is required, “gui.xsd” is the GUI specification validation, so that the user’s XML specification can always be validated according to the specification rules.

1.2.2 Label

This section is to teach how a label widget can be specified in the XML document.

XML Element Name: <Label/>

Example

<Label text="Name:" name="Label1" ID="Label"/>

Figure 63

The above code specified a label on the page as shown in figure 1. The mandatory attributes for a label element is: text, name and ID. The contents of the attribute

“text” and “name” can be freely defined by you, but “ID” must set to “Label”.

“text” represents the contents of the label, means the output result.

“name” is the assigned value of the label, you can assign any name to it.

If you would like to transform this widget into the Java document, the attribute “ID”

must set to “JLabel” in the XML specification as shown below:

<Label name="top" text="Member Login" ID="JLabel"/>

All the widgets have the attributes “name” and “ID”, and they all work in the same way, so I won’t describe on it for the following widgets. Notice that the attribute “ID”

is mandatory for each widget, but “name” is optional, the user can use this element when it’s needed.

1.2.3 Textbox

This section is to teach how a textbox widget can be specified in the XML document.

XML Element Name: <Edit/>

Example

<Edit size="20" name="Edit1" ID="Edit"/>

Figure 64

The above code specified a textbox as shown in figure 64. You can enter any contents into the textbox. The mandatory attributes for a textbox is: size, name and ID. The

attribute “size” is used to specify how big the textbox should be, depending on the user’s need. The “ID” must set to “Edit”.

If this textbox is specified for password, then the “ID” must set to “Password” in the XML specification, the result will be like this:

<Edit name="Code" size="10" ID="Password"/>

Figure 65

In order to transform this widget into the Java platform, the XML element has to be

<TextFieled/> and <PasswordField/> and the “ID” must set to “JTextfield” and

“JPasswordField” in the XML specification as shown below:

<TextField name="edit1" size="12" ID="JTextField"/>

<PasswordField name="edit2" size="12" ID="JPasswordField"/>

1.2.4 Button

This section is to teach how a button widget can be specified in the XML document.

XML Element Name: <Button/>

Example

<Button name="button1" value="Save" ID="Button"/>

Figure 66

There are three attributes for the button widget, “name”, “value” and “ID”. “value” is used to set the text on the button, you can enter any texts you prefer to. Again, “ID”

must set to “Button”.

If you would like to transform this widget into the Java document, the attribute “ID”

must set to “JButton” in the XML specification as shown below:

<Button name="button1" value="Submit" ID="JButton"/>

1.2.5 Radio Button

This section is to teach how a radio button widget can be specified in the XML document.

XML Element Name: <Radio/>

Child element Name: <Item/>

Example

<Radio size="1" name="1" ID="Radio">

<Item name="sex" value="male" ID="Radio"/>

<Item name="sex" value="female" ID="Radio"/>

</Radio>

Figure 67

You can make single selection with this widget. This element contains one child element <Item/>, which is used to specify the contents of the radio buttons. The attribute “value” is to specify the contents of the item. The attribute “ID” must be

“Radio”. The attribute “size” is used to specify the size of the radio button, i.e. how big it can be.

1.2.6 Checkbox

This section is to teach how a checkbox widget can be specified in the XML document.

XML Element Name: <Checkbox/>

Child element Name: <Item/>

Example

<Checkbox size="1" ID="Checkbox">

<Item name="C1" value="xml" ID="Checkbox"/>

<Item name="C2" value="html" ID="Checkbox"/>

<Item name="C3" value="java" ID="Checkbox"/>

</Checkbox>

Figure 68

You can make multi selections with this widget. This element contains one child element <Item/>, which is used to specify the contents of the checkboxes. The attribute “value” is to specify the contents of the item. The attribute “ID” must be

“Checkbox”. The attribute “size” is used to specify the size of the checkbox, i.e. how big it can be.

1.2.7 Drop-down Menu

This section is to teach how a checkbox widget can be specified in the XML document.

XML Element Name: <Select/>

Child element Name: <Item/>

Example

<Select size="1" name="select1" ID="Select">

<Item value="Denmark"/>

<Item value="China"/>

<Item value="England"/>

</Select>

Figure 69

You can make selections with this widget. This element contains one child element

<Item/>, which is used to specify the contents of the drop-down menu. The attribute

“value” is to specify the contents of the item. The attribute “ID” must be “Select”. The attribute “size” is used to specify the size of the drop-down menu, i.e. how big it can be.

1.2.8 Listbox

This section is to teach how a listbox widget can be specified in the XML document.

XML Element Name: <Listbox/>

Example

<Listbox name="S1" rows="6" cols="30" ID="Listbox"/>

Figure 70

This widget is also used to enter the texts, just like the textbox, but it provides much more spaces. The attributes for this element is: “name”, “rows”, “cols”, and “ID”. The

“rows” represents the height of the list box and “cols” represents the width of the list box. The attribute “name” can be set to any, but “ID” must set to “Listbox”.

In document XML Specification of GUI (Sider 93-97)