File: tutorial.txt

package info (click to toggle)
tdtd 0.7.1-5
  • links: PTS
  • area: main
  • in suites: potato
  • size: 200 kB
  • ctags: 154
  • sloc: lisp: 1,944; sh: 78; makefile: 43
file content (300 lines) | stat: -rw-r--r-- 9,175 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
This is a short tutorial on using dtd-mode when creating new
declarations and working with existing declarations in DTD files.

This tutorial uses the following conventions:

   Control keys are written with the prefix "C-".

   Meta key combinations are written with the prefix "M-".

   The return key is written as "RET".

   The space character is written as "SPACE".

   Sequences of keys are written with space between them, and the
   space character should not be typed.

   Input terminated by RET is generally written with "Enter...".

   Input that does not need RET is generally written with "Type...".


* CREATING A NEW DTD

You are going to create the following DTD file:

------------------------------------------------------------
<?xml version="1.0"?>
<!-- ============================================================= -->
<!--                    dtd-mode tutorial DTD                      -->
<!-- ============================================================= -->

<!--                    Paragraph Content                          -->
<!--                    Content allowed inside paragraphs          -->
<!ENTITY % paracon     "#PCDATA | list"                              >

<!--                    Book                                       -->
<!ELEMENT  book         (para | list)+                               >

<!--                    Paragraph                                  -->
<!ELEMENT  para         (%paracon;)*                                 >

<!--                    List                                       -->
<!ELEMENT  list         item+                                        >
<!--         type       Specifies the formatting applied to the list
                        items
             id         Unique identifier                          -->
<!ATTLIST  list
             type       (ordered | unordered)              #REQUIRED
             id         ID                                 #IMPLIED  >

<!--                    List Item                                  -->
<!ELEMENT  item         (para | list)+                               >

<!--                    End of dtd-mode tutorial DTD               -->
------------------------------------------------------------


1. Find the file "tutorial.dtd":

   1.1 Enter "C-x C-f tutorial.dtd".

       Since it doesn't exist, Emacs will create it.

2. Enter the XML declaration:

   <?xml version="1.0"?>

3. Enter the comment "dtd-mode tutorial DTD":

   3.1 Type "C-u C-c C-c".

   3.2 At the prompt, enter "dtd-mode tutorial DTD".

4. Insert a blank line, then enter the internal parameter entity
   declaration:

   4.1 Type "C-c C-%".

   4.2 At the first prompt, enter "paracon".

   4.3 At the successive prompts, enter "Paragraph Content", "Content
       allowed inside paragraphs", and "#PCDATA | list".

5. Insert a blank line, then enter the <book> element type
   declaration:

   5.1 Type "C-c C-e".

   5.2 At the first prompt, enter "book".

   5.3 At the successive prompts, enter (or change to make) "Book", ""
       (since we're not bothering with a comment), and "(para |
       list)+".

6. Create a TAGS file:

   6.1 Type "C-x C-s" to save "tutorial.dtd".

   6.2 Enter "M-x dtd-etags".

   6.3 At the prompt, enter "tutorial.dtd".

7. Insert a blank line then enter the <para> element type declaration:

   7.1 Type "C-c C-e".

   7.2 At the prompt, accept "para" as the default.

       Note that you can scroll through this history list (and all
       other minibuffer history lists) with "M-p" and "M-n".

   7.3 At the next two prompts, enter (or change to make) "Paragraph"
       and "".

   7.4 At the content specification prompt, type "(%", then type
       "M-TAB" if using Emacs 19.34 ("ESC TAB" if using NTEmacs,
       "C-u M-TAB" if using Emacs 20.3, or "C-u ESC TAB" if using
       NTEmacs 20.3).

       Emacs will complete the parameter entity name using the
       information from the TAGS file created with `dtd-etags'.

   7.5 Enter ")*" to complete the content specification.

8. Insert a blank line, then enter the <list> element type
   declaration:

   8.1 Type "C-c C-e".

   8.2 At the prompt, accept "list" as the default.

       "list" is now the default since "para" was removed from the
       history list when the <para> element type was declared.

   8.3 At the successive prompts, enter "List", "", and "item+".

9. Enter the attribute list declaration for <list>:

   9.1 Type "C-c C-a".

   9.2 At the prompt, accept "list" as the element type name.

   9.3 At successive prompts, enter "type", "Specifies the formatting
       applied to the list items", and "(ordered | unordered)".

   9.4 At the prompt for the default, type "M-p M-p" to select
       "#REQUIRED".

   9.5 Type "C-c C-a".

   9.6 At successive prompts, enter "id" and "Unique identifier".

   9.7 At the prompt for the attribute type, repeatedly type "M-p"
       until the prompt value is "ID".

       "ID" is present because the attribute type minibuffer was
       initialised with the attribute types allowed in XML.

   9.8 At the default prompt, repeatedly type "M-p" until the prompt
       value is "#IMPLIED".

       Note how the minibuffer history list keeps the most recently
       used value at the head of the list.

       When the second attribute is entered, its comment is merged
       with that of the first attribute, and the ">" at the end of the
       attribute list declaration is moved to after the declaration
       for the second attribute.  If point (i.e. the cursor position)
       had been before the declaration for the first attribute, the
       second attribute would have been inserted before the first.

10. Insert a blank line, then enter the declaration for <item>.

    Note that "item" is the default in the "Element tag" minibuffer
    history list and, since the <item> content model is that same as
    that for <book>, the content specification can be recalled from
    the minibuffer history list for content specifications.

11. Insert a blank line, then enter the closing comment:

    11.1 Type "C-c C-c".

    11.2 Enter "End of dtd-mode tutorial DTD".

12. Enter "C-x C-s" to save the file.


* WORKING WITH AN EXISTING DTD

1. Open or create tutorial.dtd.

   1.1 Enter "C-x C-f tutorial.dtd".

2. Update the TAGS file:

   2.1 Enter "M-x dtd-etags".

   2.2 If necessary, enter "tutorial.dtd".

3. Find the declaration for <para>:

   3.1 Type "M-.".

   3.2 At the prompt, enter "para".

       Point moves to the first token in the content model for <para>.

4. Find the declaration for %paracon; in another window:

   4.1 Type "C-x 4 .".

   4.2 Enter "RET" to accept the default.

       Point moves to the first token in the replacement text for
       %paracon;.

5. Find the declarations for <list>:

   5.1 Type "M-f M-f" to move point to the "list" text.

   5.2 Type "M-." and accept the default.

       Point moves to the first token in the <list> content
       specification.

   5.3 Type "M-0 M-.".

       Emacs uses the same tag, moves to the next occurrence of the
       <list> element type name, and leaves point at the start of the
       first attribute name.

   5.4 Type "M-- M-.".

       Point moves back to the previous use of the <list> element type
       name.

6. Find all occurrences of "list":

   6.1 Enter "M-x dtd-grep".

   6.2 Enter "list".

   6.3 Accept the default file specification, since it is the same as
       was used with `dtd-etags'.

       The other window shows all occurrences of "list" in the
       tutorial.dtd.

   6.4 Type "C-x `".

       Point moves to the first occurrence of "list", and the *grep*
       buffer scrolls to place the corresponding line at the top of
       the window.

   6.5 Move to another line in the other window (e.g. type "C-x o C-n
       C-n C-n") then type "RET".

       Point moves to that occurrence of "list" in tutorial.dtd, and
       the *grep* buffer scrolls to place the line at the top of the
       buffer.

7. Change all "paracon" to "ParaContent":

   7.1 Enter "M-x tags-query-replace".

   7.2 Enter "paracon" at the first prompt, and "ParaContent" at the
       second.

   7.3 Type "SPACE SPACE" to perform the two replacements.

       These changes could have been done with `query-replace-regexp'
       since we're working with a single file, but
       `tags-query-replace' will also work across multiple files.

       Since there isn't yet a auto-fill function for declarations,
       the changed declarations need fixing.

   7.4 Type "C-c >".

       The ">" ending the declaration moves to the correct column.
       This same function will insert a ">" if there isn't one on the
       line, and will insert or move "-->" if inside a comment.

   7.5 Fix the other declaration manually.

       One day there'll be an auto-fill function...

8. Use the "Goto" menu to find the declaration for <item>:

   8.1 Under the "Goto" menu, select the "item" entry.

       Point moves to the first token in the <item> content
       specification.

9. Type "C-x C-s" to save the file.


-----
$Id: tutorial.txt,v 1.6 1999/03/23 13:33:40 tkg Exp $
$Name: tdtd071 $