filler30.gif (46 octets) This tutorial will show you how to create a DTD and a XML file for this DTD.

Create a new DTD document.
Select menu File New DTD or press the File New Icon new2.gif (908 octets) while the 'DTD Schema' tab is selected.


Create a new DTD Element
Select the DTD Schema tab
In the DTD tree, select the Element(s) leaf.

tutor1.gif (2949 octets)

Select menu Edit Insert After or press the Insert After icon insafter.gif (913 octets)
An Element is inserted in the tree and selected. The form for element creation and modification is loaded in the right panel. A default element name of 'New Element' is given. The content model is set to EMPTY.

tutor2.gif (6082 octets)

In the name field, change 'New Element' for 'from'.
In the Available list, select the 'GroupStart' item and press the Add button.
In the Available list, select the '#PCDATA' item and press the Add button.
In the Available list, select the 'GroupEnd' item and press the Add button.
At the bottom of this panel, press the Create button.

tutor3.gif (6745 octets)

Change the text in the Name field from 'from' to 'to' and press the Create button.
In the Available list, select the 'GroupStart' item and press the Add button.
In the Available list, select the '#PCDATA' item and press the Add button.
In the Available list, select the 'GroupEnd' item and press the Add button.

Change the text in the Name field from 'to' to 'cc' and press the Create button.
In the Available list, select the 'GroupStart' item and press the Add button.
In the Available list, select the '#PCDATA' item and press the Add button.
In the Available list, select the 'GroupEnd' item and press the Add button.

Change the text in the Name field from 'cc' to 'date' and press the Create button.
In the Available list, select the 'GroupStart' item and press the Add button.
In the Available list, select the '#PCDATA' item and press the Add button.
In the Available list, select the 'GroupEnd' item and press the Add button.

Change the text in the Name field from 'date' to 'p' and press the Create button.
In the Available list, select the 'GroupStart' item and press the Add button.
In the Available list, select the '#PCDATA' item and press the Add button.
In the Available list, select the 'GroupEnd' item and press the Add button.

We will create now the content element.
Change the text in the Name field from 'p' to 'content' and press the Create button.
In the Available list, select the 'GroupStart' item and press the Add button.
In the Available list, select the 'p' item and press the Add button.
In the Available list, select the 'GroupEnd' item and press the Add button.
In the Selected list, select the 'p' item and press the right mouse button. A popup menu appears. In the Occurrence section, choose the One or More (+) radio button and press the Modify button. This qualification specified that there should be at least one paragraph in the memo.

tutor4.gif (4628 octets)

We will create now the memo element.
Change the text in the Name field from 'content' to 'memo' and press the Create button.
In the Available list, select the 'GroupStart' item and press the Add button.
In the Available list, select the 'from' item and press the Add button.
In the Available list, select the 'to' item and press the Add button.
In the Available list, select the 'cc' item and press the Add button.
In the Available list, select the 'date' item and press the Add button.
In the Available list, select the 'content' item and press the Add button.
In the Available list, select the 'GroupEnd' item and press the Add button.
In the Selected list, select the 'cc' item and press the right mouse button. A popup menu appears. In the Occurrence section, choose the Zero, one or More (*) radio button and press the Modify button.
This qualification specified that zero, one or more carbon copy can be entered in the memo.


tutor5.gif (16697 octets)

You can reorder the elements in the DTD tree on the left. In this tutorial, we will shift up the 'memo' element until it is the first element in the list.

Shift up a DTD item.
Select the item you wish to shift up.
Select the menu View Shift Up or press the Shift Up icon up.gif (870 octets)

We will also shift down the 'p' element under the 'content' element.

Shift down a DTD item.
Select the item you wish to shift down.
Select the menu View Shift Down or press the Shift Down icon down.gif (873 octets)

Here is a view of the tree after the moving of elements.

tutor6.gif (3983 octets)

 

Create a DTD element Attributes
Select the DTD Schema tab
In the DTD tree, select the Element(s) leaf and expand it.

Select the element you wish to add attribute.
Select the menu Edit Insert Attribute to insert an attribute for an element. The new attribute will be place at the end of the attributes list for this element.

Or select an attribute in the list of attributes for an element and select the menu Edit Insert After insafter.gif (913 octets) to insert an attribute after the one selected or select the menu Edit Insert Above insbefore.gif (905 octets) to insert an attribute above the one selected.

In this tutorial, we will create an attribute for the 'memo' element.
Select the 'memo' element.
An Attribute is inserted in the tree under the selected element and become selected. The form for attribute creation and modification is loaded in the right panel. A default attribute name of 'New Attribute' is given. The attribute type is set to CDATA and the presence is set to IMPLIED.

tutor9.gif (5254 octets)

In the name field, change 'New Attribute' for 'distribution'.
In the Type list box, select the 'ENUMERATION' item.
In the Values list box, enter 'public' and press the Add button.
In the Values list box, enter 'private' and press the Add button.
In the Default list box, select the 'public' item.
In the Presence list box, select the 'DEFAULT' item.
At the bottom of this panel, press the Create button.

Here is a screen shot

tutor10.gif (5740 octets)

View the source code of a DTD document
Select the Source tab
Select menu View DTD Source

tutor11.gif (5495 octets)

It is a good idea at this stage to save our work.

Save a document with the Save DTD As... option.
Select menu File Save DTD As... or press the save as icon saveas.gif (147 octets) while the 'DTD Schema' tab is selected.
A Save As dialog box asks you for a file name. Enter the name you want for your DTD file.

In this tutorial, we will change the directory folder by selecting the 'samples' folder. We will name our DTD, memo.dtd and press the Save button.

You can sort items in a DTD section of the tree.
Select the section you wish to sort. Select one of Notation(s), Entity(ies) or Element(s).
Select menu View Sort or press the Sort icon sortasc.gif (142 octets)

We are now ready to create a XML document related to our memo DTD.

Create a new XML document.
Select menu File New XML or press the File New Icon new2.gif (908 octets) while the 'XML Document' tab is selected.


Create a new XML Element
Select the XML Document tab
In the XML tree, select the Document leaf.

Select menu Edit Set Root. The form for the DOCTYPE creation and modification is loaded in the right panel. The System Id. is set to the current DTD, 'memo.dtd'. Select 'memo' in the Root Element list box and enter 'memo' in the Doctype field.
At the bottom of this panel, press the Set button.

Here is a view

tutor13.gif (4159 octets)

and the right panel change to

tutor14.gif (6315 octets)

The upper part of this screen is a display of the element name and the text of this element. These fields are read only. The middle is a list of the available attributes for this element that are not already assign. Another list give the available elements base on the content model for this element. The lower part of the panel show the DTD declaration for this element.

In the Attribute(s) list box, select the 'distribution' item and press the Insert button right to it.
This attribute is added to the 'memo' element and is selected ready for edition.

tutor15.gif (5041 octets)

In the Values list box, select the 'private' item and press the Modify button below.
In the lower part of the panel, you can insert other attributes for this elements if there are some available to insert.

In the XML tree at the left, select the 'memo' item.
In the Available Element(s) list box, select the 'from' item and press the Insert button right to it. This element is added to the 'memo' element and is selected ready for edition.

In the Available Element(s) list box, select the '#PCDATA' item and press the Insert button right to it. This element is added to the 'from' element and is selected ready for edition.

In the PCDATA panel, enter 'Pierre Morel' in the text box and press the Modify button below.

tutor16.gif (3623 octets)

In the XML tree at the left, select the 'memo' item.
In the Available Element(s) list box, select the 'to' item and press the Insert button right to it. This element is added to the 'memo' element and is selected ready for edition.

In the Available Element(s) list box, select the '#PCDATA' item and press the Insert button right to it. This element is added to the 'to' element and is selected ready for edition.

In the PCDATA panel, enter 'Michel Morin' in the text box and press the Modify button below.

In the XML tree at the left, select the 'memo' item.
In the Available Element(s) list box, select the 'date' item and press the Insert button right to it. This element is added to the 'memo' element and is selected ready for edition.

In the Available Element(s) list box, select the '#PCDATA' item and press the Insert button right to it. This element is added to the 'date' element and is selected ready for edition.

In the PCDATA panel, enter 'Mon, 20 Apr 1998' in the text box and press the Modify button below.

In the XML tree at the left, select the 'memo' item.
In the Available Element(s) list box, select the 'content' item and press the Insert button right to it. This element is added to the 'memo' element and is selected ready for edition.

In the Available Element(s) list box, select the 'p item and press the Insert button right to it. This element is added to the 'content' element and is selected ready for edition.

In the Available Element(s) list box, select the '#PCDATA' item and press the Insert button right to it. This element is added to the 'p' element and is selected ready for edition.

In the PCDATA panel, enter 'Hi, this is my first XML document. If you are a programmer, should read Hello world!. Bye' in the text box and press the Modify button below.

The screen should look like this.

tutor17.gif (12304 octets)

 

View the source code of a XML document
Select the Source tab
Select menu View XML Source

tutor18.gif (5781 octets)

Save a document with the Save XML As... option.
Select menu File Save XML As... or press the save as icon saveas.gif (147 octets) while the 'XML Document' tab is selected.
A Save As dialog box asks you for a file name. Enter the name you want for your XML file.

In this tutorial, we will change the directory folder by selecting the 'samples' folder. We will name our XML, memo.xml and press the Save button.

Shift up a XML item.
Select the item you wish to shift up.
Select the menu View Shift Up or press the Shift Up icon up.gif (870 octets)

Shift down a XML item.
Select the item you wish to shift down.
Select the menu View Shift Down or press the Shift Down icon down.gif (873 octets)

Attributes are included first as leaf for an element. After that, elements that are part of the content model are included. Remember to move element by following the order specified in the content model.


© 1997-98   9036-6733 Québec Inc. All rights reserved.