added some development tools
[windows-sources.git] / developer / Samples / Bot / library / reference / aiml.xsd
blob6e77dace4f0c57a19b1295815c3665f5205b891c
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xs:schema xmlns="http://alicebot.org/2001/AIML-1.0.1" xmlns:xs="http://www.w3.org/2001/XMLSchema"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 xmlns:sch="http://www.ascc.net/xml/schematron"
5 targetNamespace="http://alicebot.org/2001/AIML-1.0.1" elementFormDefault="qualified"
6 attributeFormDefault="unqualified" version="1.0" xml:lang="EN">
7 <xs:element name="aiml">
8 <xs:annotation>
9 <xs:documentation>An AIML object is represented by an aiml element in an XML document.</xs:documentation>
10 <xs:appinfo>
11 <sch:title>Schematron validation</sch:title>
12 <sch:ns prefix="aiml" uri="http://alicebot.org/2001/AIML-1.0.1"/>
13 </xs:appinfo>
14 </xs:annotation>
15 <xs:complexType>
16 <xs:choice minOccurs="1" maxOccurs="unbounded">
17 <xs:element name="topic">
18 <xs:complexType>
19 <xs:annotation>
20 <xs:documentation>A topic is an optional top-level element that contains
21 category elements. A topic element has a required name attribute
22 that must contain a simple pattern expression. A topic element may
23 contain one or more category elements.</xs:documentation>
24 </xs:annotation>
25 <xs:sequence maxOccurs="unbounded">
26 <xs:element name="category" type="Category"/>
27 </xs:sequence>
28 <xs:attribute name="name" type="SimplePatternExpression" use="required"/>
29 </xs:complexType>
30 </xs:element>
31 <xs:element name="category" type="Category"/>
32 </xs:choice>
33 <xs:attribute name="version" use="required">
34 <xs:simpleType>
35 <xs:restriction base="xs:string">
36 <xs:enumeration value="1.0.1"/>
37 </xs:restriction>
38 </xs:simpleType>
39 </xs:attribute>
40 </xs:complexType>
41 </xs:element>
42 <xs:complexType name="Category">
43 <xs:annotation>
44 <xs:documentation>A category is a top-level (or second-level, if contained within a
45 topic) element that contains exactly one pattern and exactly one template. A
46 category does not have any attributes. All category elements that do not occur as
47 children of an explicit topic element must be assumed by the AIML interpreter to
48 occur as children of an "implied" topic whose name attribute has the value * (single
49 asterisk wildcard).</xs:documentation>
50 </xs:annotation>
51 <xs:sequence>
52 <xs:element name="pattern" type="MixedPatternExpression">
53 <xs:annotation>
54 <xs:documentation>A pattern is an element whose content is a mixed pattern
55 expression. Exactly one pattern must appear in each category. The pattern
56 must always be the first child element of the category. A pattern does not
57 have any attributes. The contents of the pattern are appended to the full
58 match path that is constructed by the AIML interpreter at load
59 time.</xs:documentation>
60 </xs:annotation>
61 </xs:element>
62 <xs:element name="that" type="MixedPatternExpression" minOccurs="0">
63 <xs:annotation>
64 <xs:documentation>The pattern-side that element is a special type of pattern
65 element used for context matching. The pattern-side that is optional in a
66 category, but if it occurs it must occur no more than once, and must
67 immediately follow the pattern and immediately precede the template. A
68 pattern-side that element contains a simple pattern expression. The contents
69 of the pattern-side that are appended to the full match path that is
70 constructed by the AIML interpreter at load time. If a category does not
71 contain a pattern-side that, the AIML interpreter must assume an "implied"
72 pattern-side that containing the pattern expression * (single asterisk
73 wildcard).</xs:documentation>
74 </xs:annotation>
75 </xs:element>
76 <xs:element name="template" type="MixedTemplateContentContainer">
77 <xs:annotation>
78 <xs:documentation>The majority of AIML content is within the template. The
79 template may contain zero or more AIML template elements mixed with
80 character data.</xs:documentation>
81 </xs:annotation>
82 </xs:element>
83 </xs:sequence>
84 </xs:complexType>
85 <xs:complexType name="MixedPatternExpression" mixed="true">
86 <xs:annotation>
87 <xs:documentation>A mixed pattern expression is composed from one or more mixed pattern
88 expression constituents, separated by XML spaces (&amp;#x20).</xs:documentation>
89 </xs:annotation>
90 <!--<xs:complexContent mixed="true">
91 <xs:extension base="SimplePatternExpression">-->
92 <xs:choice minOccurs="0" maxOccurs="unbounded">
93 <xs:element name="bot" type="BotPredicate"/>
94 </xs:choice>
95 <!--</xs:extension>
96 </xs:complexContent>-->
97 </xs:complexType>
98 <xs:simpleType name="SimplePatternExpression">
99 <xs:annotation>
100 <xs:documentation>A simple pattern expression is composed from one or more simple
101 pattern expression constituents, separated by XML spaces (#x20).</xs:documentation>
102 </xs:annotation>
103 <xs:restriction base="xs:string">
104 <xs:minLength value="1"/>
105 <xs:pattern value="((\d|\p{Lu})+|\*|_)( +((\d|\p{Lu})+|\*|_))*"/>
106 </xs:restriction>
107 </xs:simpleType>
108 <xs:complexType name="MixedTemplateContentContainer" mixed="true">
109 <xs:choice minOccurs="0" maxOccurs="unbounded">
110 <xs:group ref="atomicElements"/>
111 <xs:group ref="textFormattingElements"/>
112 <xs:group ref="conditionalElements"/>
113 <xs:group ref="captureElements"/>
114 <xs:group ref="symbolicReductionElements"/>
115 <xs:group ref="transformationalElements"/>
116 <xs:group ref="covertElements"/>
117 <xs:group ref="externalProcessorElements"/>
118 <xs:any namespace="##other" processContents="lax"/>
119 </xs:choice>
120 </xs:complexType>
121 <xs:group name="atomicElements">
122 <xs:annotation>
123 <xs:documentation>An atomic template element in AIML indicates to an AIML interpreter
124 that it must return a value according to the functional meaning of the element.
125 Atomic elements do not have any content.</xs:documentation>
126 </xs:annotation>
127 <xs:choice>
128 <xs:element name="star" type="IndexedElement">
129 <xs:annotation>
130 <xs:documentation>The star element indicates that an AIML interpreter should
131 substitute the value "captured" by a particular wildcard from the
132 pattern-specified portion of the match path when returning the template. The
133 star element has an optional integer index attribute that indicates which
134 wildcard to use. The minimum acceptable value for the index is "1" (the
135 first wildcard), and the maximum acceptable value is equal to the number of
136 wildcards in the pattern. </xs:documentation>
137 </xs:annotation>
138 </xs:element>
139 <xs:element name="that" type="OneOrTwoDIndexedElement">
140 <xs:annotation>
141 <xs:documentation>The pattern-side that element is a special type of pattern
142 element used for context matching. The pattern-side that is optional in a
143 category, but if it occurs it must occur no more than once, and must
144 immediately follow the pattern and immediately precede the template. A
145 pattern-side that element contains a simple pattern expression. The contents
146 of the pattern-side that are appended to the full match path that is
147 constructed by the AIML interpreter at load time. If a category does not
148 contain a pattern-side that, the AIML interpreter must assume an "implied"
149 pattern-side that containing the pattern expression * (single asterisk
150 wildcard). </xs:documentation>
151 </xs:annotation>
152 </xs:element>
153 <xs:element name="input" type="OneOrTwoDIndexedElement">
154 <xs:annotation>
155 <xs:documentation>The input element tells the AIML interpreter that it should
156 substitute the contents of a previous user input. The template-side input
157 has an optional index attribute that may contain either a single integer or
158 a comma-separated pair of integers. The minimum value for either of the
159 integers in the index is "1". The index tells the AIML interpreter which
160 previous user input should be returned (first dimension), and optionally
161 which "sentence" of the previous user input. The AIML interpreter should
162 raise an error if either of the specified index dimensions is invalid at
163 run-time. An unspecified index is the equivalent of "1,1". An unspecified
164 second dimension of the index is the equivalent of specifying a "1" for the
165 second dimension.</xs:documentation>
166 </xs:annotation>
167 </xs:element>
168 <xs:element name="thatstar" type="IndexedElement">
169 <xs:annotation>
170 <xs:documentation>The thatstar element tells the AIML interpreter that it should
171 substitute the contents of a wildcard from a pattern-side that element. The
172 thatstar element has an optional integer index attribute that indicates
173 which wildcard to use; the minimum acceptable value for the index is "1"
174 (the first wildcard). An AIML interpreter should raise an error if the index
175 attribute of a star specifies a wildcard that does not exist in the that
176 element's pattern content. Not specifying the index is the same as
177 specifying an index of "1".</xs:documentation>
178 </xs:annotation>
179 </xs:element>
180 <xs:element name="topicstar" type="IndexedElement">
181 <xs:annotation>
182 <xs:documentation> The topicstar element tells the AIML interpreter that it
183 should substitute the contents of a wildcard from the current topic (if the
184 topic contains any wildcards). The topicstar element has an optional integer
185 index attribute that indicates which wildcard to use; the minimum acceptable
186 value for the index is "1" (the first wildcard). Not specifying the index is
187 the same as specifying an index of "1".</xs:documentation>
188 </xs:annotation>
189 </xs:element>
190 <xs:element name="get">
191 <xs:annotation>
192 <xs:documentation> The get element tells the AIML interpreter that it should
193 substitute the contents of a predicate, if that predicate has a value
194 defined. If the predicate has no value defined, the AIML interpreter should
195 substitute the empty string "". The AIML interpreter implementation may
196 optionally provide a mechanism that allows the AIML author to designate
197 default values for certain predicates.</xs:documentation>
198 </xs:annotation>
199 <xs:complexType>
200 <xs:attribute name="name" type="PredicateName"/>
201 </xs:complexType>
202 </xs:element>
203 <xs:element name="bot" type="BotPredicate"/>
204 <xs:group ref="shortcutElements"/>
205 <xs:group ref="systemDefinedPredicates"/>
206 </xs:choice>
207 </xs:group>
208 <xs:complexType name="BotPredicate">
209 <xs:annotation>
210 <xs:documentation> An element called bot, which may be considered a restricted
211 version of get, is used to tell the AIML interpreter that it should
212 substitute the contents of a "bot predicate". The value of a bot predicate
213 is set at load-time, and cannot be changed at run-time. The AIML interpreter
214 may decide how to set the values of bot predicate at load-time. If the bot
215 predicate has no value defined, the AIML interpreter should substitute an
216 empty string.</xs:documentation>
217 </xs:annotation>
218 <xs:attribute name="name" type="PredicateName" use="required"/>
219 </xs:complexType>
220 <xs:group name="shortcutElements">
221 <xs:annotation>
222 <xs:documentation>Several atomic AIML elements are "short-cuts" for combinations of
223 other AIML elements.</xs:documentation>
224 </xs:annotation>
225 <xs:choice>
226 <xs:element name="sr">
227 <xs:annotation>
228 <xs:documentation>The sr element is a shortcut for:
229 &lt;srai&gt;&lt;star/&gt;&lt;/srai&gt; The atomic sr
230 does not have any content. </xs:documentation>
231 </xs:annotation>
232 </xs:element>
233 <!--
234 <xs:element name="person" xsi:type="IndexedElement">
235 <xs:annotation>
236 <xs:documentation>The atomic version of the person element is a shortcut for:
237 &lt;person&gt;&lt;star/&gt;&lt;/person&gt; The
238 atomic person does not have any content. </xs:documentation>
239 </xs:annotation>
240 </xs:element>
241 <xs:element name="person2" xsi:type="IndexedElement">
242 <xs:annotation>
243 <xs:documentation>The atomic version of the person2 element is a shortcut for:
244 &lt;person2&gt;&lt;star/&gt;&lt;/person2&gt; The
245 atomic person does not have any content. </xs:documentation>
246 </xs:annotation>
247 </xs:element>
248 <xs:element name="gender" xsi:type="IndexedElement">
249 <xs:annotation>
250 <xs:documentation>The atomic version of the gender element is a shortcut for:
251 &lt;gender&gt;&lt;star/&gt;&lt;/gender&gt; The
252 atomic gender does not have any content. </xs:documentation>
253 </xs:annotation>
254 </xs:element>
256 </xs:choice>
257 </xs:group>
258 <xs:group name="systemDefinedPredicates">
259 <xs:annotation>
260 <xs:documentation>Several atomic AIML elements require the AIML interpreter to
261 substitute a value that is determined from the system, independently of the AIML
262 content.</xs:documentation>
263 </xs:annotation>
264 <xs:choice>
265 <xs:element name="date">
266 <xs:annotation>
267 <xs:documentation> The date element tells the AIML interpreter that it should
268 substitute the system local date and time. No formatting constraints on the
269 output are specified.</xs:documentation>
270 </xs:annotation>
271 </xs:element>
272 <xs:element name="id">
273 <xs:annotation>
274 <xs:documentation>The id element tells the AIML interpreter that it should
275 substitute the user ID. The determination of the user ID is not specified,
276 since it will vary by application. A suggested default return value is
277 "localhost".</xs:documentation>
278 </xs:annotation>
279 </xs:element>
280 <xs:element name="size">
281 <xs:annotation>
282 <xs:documentation>The size element tells the AIML interpreter that it should
283 substitute the number of categories currently loaded.</xs:documentation>
284 </xs:annotation>
285 </xs:element>
286 <xs:element name="version">
287 <xs:annotation>
288 <xs:documentation>The version element tells the AIML interpreter that it should
289 substitute the version number of the AIML interpreter.</xs:documentation>
290 </xs:annotation>
291 </xs:element>
292 </xs:choice>
293 </xs:group>
294 <xs:group name="textFormattingElements">
295 <xs:annotation>
296 <xs:documentation>Text-formatting elements instruct an AIML interpreter to perform
297 locale-specific post-processing of the textual results of the processing of their
298 contents.</xs:documentation>
299 </xs:annotation>
300 <xs:choice>
301 <xs:element name="uppercase" type="MixedTemplateContentContainer"/>
302 <xs:element name="lowercase" type="MixedTemplateContentContainer"/>
303 <xs:element name="formal" type="MixedTemplateContentContainer"/>
304 <xs:element name="sentence" type="MixedTemplateContentContainer"/>
305 </xs:choice>
306 </xs:group>
307 <xs:group name="conditionalElements">
308 <xs:choice>
309 <xs:element name="condition">
310 <xs:annotation>
311 <xs:documentation>The condition element instructs the AIML interpreter to return
312 specified contents depending upon the results of matching a predicate
313 against a pattern. NOTE: The definition in this Schema is currently far too
314 permissive. AIML conditions have several forms and constraints that can't be
315 expressed using W3C Schema alone. For this reason, AIML objects that
316 validate using this Schema alone may not actually be valid AIML.</xs:documentation>
317 <xs:appinfo>
318 <sch:pattern name="valid condition type">
319 <sch:rule context="aiml:condition">
320 <sch:assert
321 test="(@name and @value and not(aiml:li)) or (@name and not(@value) and aiml:li[@value and not(@name)] and not(aiml:li[@name]) and count(aiml:li[not(@value) and not(@name)]) &lt;= 1) or (not(@name) and not(@value) and aiml:li[@name and @value] and not(aiml:li[(@name and not(@value)) or (@value and not(@name))]) and count(aiml:li[not(@value) and not(@name)]) &lt;= 1)"
322 > A condition must be a block condition, a single-predicate
323 condition, or a multi-predicate condition. </sch:assert>
324 </sch:rule>
325 </sch:pattern>
326 </xs:appinfo>
327 </xs:annotation>
328 <xs:complexType mixed="true">
329 <!--
330 <xs:choice>
331 <xs:sequence minOccurs="0" maxOccurs="unbounded">
332 <xs:element name="li">
333 <xs:complexType>
334 <xs:complexContent>
335 <xs:extension base="MixedTemplateContentContainer">
336 <xs:attribute name="name" type="PredicateName"/>
337 <xs:attribute name="value" type="SimplePatternExpression"/>
338 </xs:extension>
339 </xs:complexContent>
340 </xs:complexType>
341 </xs:element>
342 </xs:sequence>
344 <xs:sequence minOccurs="0" maxOccurs="unbounded">
345 <xs:any namespace="##any" processContents="lax"/>
346 </xs:sequence>
347 <!--
348 </xs:choice>
350 <xs:attribute name="name" type="PredicateName"/>
351 <xs:attribute name="value" type="SimplePatternExpression"/>
352 </xs:complexType>
353 </xs:element>
354 <xs:element name="random">
355 <xs:annotation>
356 <xs:documentation>The random element instructs the AIML interpreter to return
357 exactly one of its contained li elements randomly.</xs:documentation>
358 </xs:annotation>
359 <xs:complexType>
360 <xs:sequence>
361 <xs:element name="li" type="MixedTemplateContentContainer"
362 maxOccurs="unbounded"/>
363 </xs:sequence>
364 </xs:complexType>
365 </xs:element>
366 </xs:choice>
367 </xs:group>
368 <xs:group name="captureElements">
369 <xs:annotation>
370 <xs:documentation>AIML defines two content-capturing elements, which tell the AIML
371 interpreter to capture their processed contents and perform some storage operation
372 with them.</xs:documentation>
373 </xs:annotation>
374 <xs:choice>
375 <xs:element name="set">
376 <xs:annotation>
377 <xs:documentation>The set element instructs the AIML interpreter to set the
378 value of a predicate to the result of processing the contents of the set
379 element. The set element has a required attribute name, which must be a
380 valid AIML predicate name. If the predicate has not yet been defined, the
381 AIML interpreter should define it in memory.</xs:documentation>
382 </xs:annotation>
383 <xs:complexType>
384 <xs:complexContent>
385 <xs:extension base="MixedTemplateContentContainer">
386 <xs:attribute name="name" type="PredicateName"/>
387 </xs:extension>
388 </xs:complexContent>
389 </xs:complexType>
390 </xs:element>
391 <xs:element name="gossip" type="MixedTemplateContentContainer">
392 <xs:annotation>
393 <xs:documentation> The gossip element instructs the AIML interpreter to capture
394 the result of processing the contents of the gossip elements and to store
395 these contents in a manner left up to the implementation. Most common uses
396 of gossip have been to store captured contents in a separate
397 file.</xs:documentation>
398 </xs:annotation>
399 </xs:element>
400 </xs:choice>
401 </xs:group>
402 <xs:group name="symbolicReductionElements">
403 <xs:choice>
404 <xs:element name="srai" type="MixedTemplateContentContainer">
405 <xs:annotation>
406 <xs:documentation> The srai element instructs the AIML interpreter to pass the
407 result of processing the contents of the srai element to the AIML matching
408 loop, as if the input had been produced by the user (this includes stepping
409 through the entire input normalization process).</xs:documentation>
410 </xs:annotation>
411 </xs:element>
412 </xs:choice>
413 </xs:group>
414 <xs:group name="transformationalElements">
415 <xs:choice>
416 <xs:element name="person" type="MixedTemplateContentContainer">
417 <xs:annotation>
418 <xs:documentation>The person element instructs the AIML interpreter to: 1.
419 replace words with first-person aspect in the result of processing the
420 contents of the person element with words with the
421 grammatically-corresponding third-person aspect; and 2. replace words with
422 third-person aspect in the result of processing the contents of the person
423 element with words with the grammatically-corresponding first-person aspect.
424 The definition of "grammatically-corresponding" is left up to the
425 implementation.</xs:documentation>
426 </xs:annotation>
427 </xs:element>
428 <xs:element name="person2" type="MixedTemplateContentContainer">
429 <xs:annotation>
430 <xs:documentation>The person2 element instructs the AIML interpreter to: 1.
431 replace words with first-person aspect in the result of processing the
432 contents of the person2 element with words with the
433 grammatically-corresponding second-person aspect; and 2. replace words with
434 second-person aspect in the result of processing the contents of the person2
435 element with words with the grammatically-corresponding first-person aspect.
436 The definition of "grammatically-corresponding" is left up to the
437 implementation.</xs:documentation>
438 </xs:annotation>
439 </xs:element>
440 <xs:element name="gender" type="MixedTemplateContentContainer">
441 <xs:annotation>
442 <xs:documentation>The gender element instructs the AIML interpreter to: 1.
443 replace male-gendered words in the result of processing the contents of the
444 gender element with the grammatically-corresponding female-gendered words;
445 and 2. replace female-gendered words in the result of processing the
446 contents of the gender element with the grammatically-corresponding
447 male-gendered words. The definition of "grammatically-corresponding" is left
448 up to the implementation. Historically, implementations of gender have
449 exclusively dealt with pronouns, likely due to the fact that most AIML has
450 been written in English. However, the decision about whether to transform
451 gender of other words is left up to the implementation.</xs:documentation>
452 </xs:annotation>
453 </xs:element>
454 </xs:choice>
455 </xs:group>
456 <xs:group name="covertElements">
457 <xs:annotation>
458 <xs:documentation>AIML defines two "covert" elements that instruct the AIML interpreter
459 to perform some processing on their contents, but to not return any
460 value.</xs:documentation>
461 </xs:annotation>
462 <xs:choice>
463 <xs:element name="think" type="MixedTemplateContentContainer">
464 <xs:annotation>
465 <xs:documentation>The think element instructs the AIML interpreter to perform
466 all usual processing of its contents, but to not return any value,
467 regardless of whether the contents produce output.</xs:documentation>
468 </xs:annotation>
469 </xs:element>
470 <xs:element name="learn">
471 <xs:simpleType>
472 <xs:annotation>
473 <xs:documentation>The learn element instructs the AIML interpreter to
474 retrieve a resource specified by a URI, and to process its AIML object
475 contents.</xs:documentation>
476 </xs:annotation>
477 <xs:restriction base="xs:anyURI"/>
478 </xs:simpleType>
479 </xs:element>
480 </xs:choice>
481 </xs:group>
482 <xs:group name="externalProcessorElements">
483 <xs:annotation>
484 <xs:documentation>AIML defines two external processor elements, which instruct the AIML
485 interpreter to pass the contents of the elements to an external processor. External
486 processor elements may return a value, but are not required to do so. Contents of
487 external processor elements may consist of character data as well as AIML template
488 elements. If AIML template elements in the contents of an external processor element
489 are not enclosed as CDATA, then the AIML interpreter is required to substitute the
490 results of processing those elements before passing the contents to the external
491 processor. AIML does not require that any contents of an external processor element
492 are enclosed as CDATA. An AIML interpreter should assume that any unrecognized
493 content is character data, and simply pass it to the appropriate external processor
494 as-is, following any processing of AIML template elements not enclosed as CDATA. If
495 an external processor is not available to process the contents of an external
496 processor element, the AIML interpreter may return an error, but this is not
497 required.</xs:documentation>
498 </xs:annotation>
499 <xs:choice>
500 <xs:element name="system" type="MixedTemplateContentContainer">
501 <xs:annotation>
502 <xs:documentation>The system element instructs the AIML interpreter to pass its
503 content (with any appropriate preprocessing) to the system command
504 interpreter of the local machine on which the AIML interpreter is
505 running.</xs:documentation>
506 </xs:annotation>
507 </xs:element>
508 <xs:element name="javascript" type="MixedTemplateContentContainer">
509 <xs:annotation>
510 <xs:documentation>The javascript element instructs the AIML interpreter to pass
511 its content (with any appropriate preprocessing, as noted above) to a
512 server-side JavaScript interpreter on the local machine on which the AIML
513 interpreter is running. The javascript element does not have any attributes.
514 AIML does not require that an AIML interpreter include a server-side
515 JavaScript interpreter, and does not require any particular behavior from
516 the server-side JavaScript interpreter if it exists. The javascript element
517 may return a value.</xs:documentation>
518 </xs:annotation>
519 </xs:element>
520 </xs:choice>
521 </xs:group>
522 <xs:complexType name="OneOrTwoDIndexedElement">
523 <xs:attribute name="index">
524 <xs:simpleType>
525 <xs:restriction base="xs:string">
526 <xs:minLength value="1"/>
527 <xs:pattern value="\d+|\d+,\d+"/>
528 </xs:restriction>
529 </xs:simpleType>
530 </xs:attribute>
531 </xs:complexType>
532 <xs:complexType name="IndexedElement">
533 <xs:attribute name="index" type="xs:integer"/>
534 </xs:complexType>
535 <xs:simpleType name="PredicateName">
536 <xs:restriction base="xs:string">
537 <xs:pattern value="\c+"/>
538 </xs:restriction>
539 </xs:simpleType>
540 </xs:schema>