/
SrgsRule.xml
726 lines (651 loc) · 46.6 KB
/
SrgsRule.xml
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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
<Type Name="SrgsRule" FullName="System.Speech.Recognition.SrgsGrammar.SrgsRule">
<TypeSignature Language="C#" Value="public class SrgsRule" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi serializable beforefieldinit SrgsRule extends System.Object" FrameworkAlternate="net-6.0;net-7.0;net-8.0;net-9.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1" />
<TypeSignature Language="DocId" Value="T:System.Speech.Recognition.SrgsGrammar.SrgsRule" />
<TypeSignature Language="VB.NET" Value="Public Class SrgsRule" />
<TypeSignature Language="F#" Value="type SrgsRule = class" />
<TypeSignature Language="C++ CLI" Value="public ref class SrgsRule" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit SrgsRule extends System.Object" FrameworkAlternate="netstandard-2.0" />
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute FrameworkAlternate="net-6.0;net-7.0;net-8.0;net-9.0">
<AttributeName Language="C#">[System.Diagnostics.DebuggerDisplay("Rule = {_id.ToString()}, Scope = {_scope.ToString()}")]</AttributeName>
<AttributeName Language="F#">[<System.Diagnostics.DebuggerDisplay("Rule = {_id.ToString()}, Scope = {_scope.ToString()}")>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="net-6.0;net-7.0;net-8.0;net-9.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.Diagnostics.DebuggerTypeProxy(typeof(System.Speech.Recognition.SrgsGrammar.SrgsRule+SrgsRuleDebugDisplay))]</AttributeName>
<AttributeName Language="F#">[<System.Diagnostics.DebuggerTypeProxy(typeof(System.Speech.Recognition.SrgsGrammar.SrgsRule+SrgsRuleDebugDisplay))>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="net-6.0;net-7.0;net-8.0;net-9.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.Serializable]</AttributeName>
<AttributeName Language="F#">[<System.Serializable>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.Diagnostics.DebuggerDisplay("Rule={_id.ToString()} Scope={_scope.ToString()}")]</AttributeName>
<AttributeName Language="F#">[<System.Diagnostics.DebuggerDisplay("Rule={_id.ToString()} Scope={_scope.ToString()}")>]</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Represents a grammar rule.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule> class to create a new rule at run time or to modify a rule in an existing grammar stream or file at run time.
The words and phrases specified by <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule> objects in grammars defined by <xref:System.Speech.Recognition.SrgsGrammar.SrgsDocument> instances limit the spoken input that the recognizer must be able to identify.
An <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule> object specifies the sequence in which words and phrases must be spoken by ordering the objects that contain them. Words and phrases within a rule are represented by objects such as <xref:System.Speech.Recognition.SrgsGrammar.SrgsItem>, <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf>, <xref:System.Speech.Recognition.SrgsGrammar.SrgsRuleRef>, and <xref:System.Speech.Recognition.SrgsGrammar.SrgsToken> elements. Use the <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule.Elements%2A> property to access the collection of child objects that an <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule> object contains.
You can determine whether an <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule> can be specified in a rule reference from a rule in an external grammar by setting its <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule.Scope%2A> property.
It is not legal to define an <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule> that is empty or that contains only white space.
This class represents the `rule` element that is defined in the World Wide Web Consortium (W3C) [Speech Recognition Grammar Specification (SRGS) Version 1.0](https://go.microsoft.com/fwlink/?LinkId=201761). For information about the SRGS `rule` element and details about its support by System.Speech, see [rule Element](https://msdn.microsoft.com/library/da67b4aa-0545-426a-a02f-1417b968021e).
]]></format>
</remarks>
<related type="Article" href="https://learn.microsoft.com/previous-versions/office/developer/speech-technologies/hh361680(v%3doffice.14)">Create Grammars Using SrgsGrammar</related>
</Docs>
<Members>
<MemberGroup MemberName=".ctor">
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Speech.Recognition.SrgsGrammar.SrgsRule" /> class.</summary>
</Docs>
</MemberGroup>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public SrgsRule (string id);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string id) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Speech.Recognition.SrgsGrammar.SrgsRule.#ctor(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (id As String)" />
<MemberSignature Language="F#" Value="new System.Speech.Recognition.SrgsGrammar.SrgsRule : string -> System.Speech.Recognition.SrgsGrammar.SrgsRule" Usage="new System.Speech.Recognition.SrgsGrammar.SrgsRule id" />
<MemberSignature Language="C++ CLI" Value="public:
 SrgsRule(System::String ^ id);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="id" Type="System.String" />
</Parameters>
<Docs>
<param name="id">The identifier of the rule.</param>
<summary>Initializes a new instance of the <see cref="T:System.Speech.Recognition.SrgsGrammar.SrgsRule" /> class and specifies the identifier for the rule.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule.%23ctor%2A> constructor initializes the <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule.Id%2A> property. The identifier must be unique within a given grammar.
The <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule.%23ctor%2A> constructor throws a <xref:System.FormatException> in the following circumstances:
- `id` is not a valid XML name, as defined in [Extensible Markup Language (XML) 1.0 (Fifth Edition)](https://www.w3.org/TR/REC-xml/). To paraphrase this definition, a valid XML name must begin with a letter, an underscore ('_'), or a colon (':') and can be followed by zero or more NameChar characters (also defined in the XML specification).
- `id` is "NULL" or "VOID" or "GARBAGE".
- `id` contains at least one invalid rule ID character. These characters are: '?', '*', '+', '|', '(', '), '^', '$', '/', ';', '.', '=', '\<', '>', '[', ']', '{', '}', '\\\\', ' ', '\t', '\r', and '\n'.
## Examples
The following example creates a grammar that recognizes the phrase "A nation that has won the World Cup is" followed by the name of a country that has won the World Cup. The example creates a <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule> object named `winnerRule` and passes in the identifier `WorldCupWinner` as a <xref:System.String>. The <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf> object consists of an array of new <xref:System.Speech.Recognition.SrgsGrammar.SrgsItem> objects containing alternatives to be recognized by the rule.
```csharp
public void WorldSoccerWinners ()
{
// Create an SrgsDocument, create a new rule
// and set its scope to public.
SrgsDocument document = new SrgsDocument();
SrgsRule winnerRule = new SrgsRule("WorldCupWinner");
winnerRule.Scope = SrgsRuleScope.Public;
// Add the introduction.
winnerRule.Elements.Add(new SrgsItem("A nation that has won the world cup is: "));
// Create the rule for the European nations.
SrgsOneOf oneOfEurope = new SrgsOneOf(new SrgsItem[] {new SrgsItem("England"),
new SrgsItem("France"), new SrgsItem("Germany"), new SrgsItem("Italy")});
SrgsRule ruleEurope = (new SrgsRule("EuropeanNations", new SrgsElement[] {oneOfEurope}));
// Create the rule for the South American nations.
SrgsOneOf oneOfSAmerica = new SrgsOneOf(new SrgsItem[] {new SrgsItem("Argentina"),
new SrgsItem("Brazil"), new SrgsItem("Uruguay")});
SrgsRule ruleSAmerica = (new SrgsRule("SouthAmericanNations", new SrgsElement[] {oneOfSAmerica}));
// Add references to winnerRule for ruleEurope and ruleSAmerica.
winnerRule.Elements.Add(new SrgsOneOf(new SrgsItem[] {(new SrgsItem
(new SrgsRuleRef(ruleEurope))), new SrgsItem(new SrgsRuleRef(ruleSAmerica))}));
// Add all the rules to the document and make winnerRule
// the root rule of the document.
document.Rules.Add(new SrgsRule[] {winnerRule, ruleEurope, ruleSAmerica});
document.Root = winnerRule;
}
```
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="id" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="id" /> is empty.</exception>
<exception cref="T:System.FormatException">
<paramref name="id" /> is not a proper rule identifier.</exception>
<related type="Article" href="https://learn.microsoft.com/previous-versions/office/developer/speech-technologies/hh361680(v%3doffice.14)">Create Grammars Using SrgsGrammar</related>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public SrgsRule (string id, params System.Speech.Recognition.SrgsGrammar.SrgsElement[] elements);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string id, class System.Speech.Recognition.SrgsGrammar.SrgsElement[] elements) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Speech.Recognition.SrgsGrammar.SrgsRule.#ctor(System.String,System.Speech.Recognition.SrgsGrammar.SrgsElement[])" />
<MemberSignature Language="VB.NET" Value="Public Sub New (id As String, ParamArray elements As SrgsElement())" />
<MemberSignature Language="F#" Value="new System.Speech.Recognition.SrgsGrammar.SrgsRule : string * System.Speech.Recognition.SrgsGrammar.SrgsElement[] -> System.Speech.Recognition.SrgsGrammar.SrgsRule" Usage="new System.Speech.Recognition.SrgsGrammar.SrgsRule (id, elements)" />
<MemberSignature Language="C++ CLI" Value="public:
 SrgsRule(System::String ^ id, ... cli::array <System::Speech::Recognition::SrgsGrammar::SrgsElement ^> ^ elements);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="id" Type="System.String" />
<Parameter Name="elements" Type="System.Speech.Recognition.SrgsGrammar.SrgsElement[]">
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.ParamArray]</AttributeName>
<AttributeName Language="F#">[<System.ParamArray>]</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<param name="id">The identifier of the rule.</param>
<param name="elements">An array of <see cref="T:System.Speech.Recognition.SrgsGrammar.SrgsElement" /> elements.</param>
<summary>Initializes a new instance of the <see cref="T:System.Speech.Recognition.SrgsGrammar.SrgsRule" /> class from an array of <see cref="T:System.Speech.Recognition.SrgsGrammar.SrgsElement" /> objects.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule.%23ctor%2A> constructor initializes the <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule.Id%2A> property. The identifier must be unique within a given grammar.
The <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule.%23ctor%2A> constructor throws a <xref:System.FormatException> in the following circumstances:
- `id` is not a valid XML name, as defined in [Extensible Markup Language (XML) 1.0 (Fifth Edition)](https://www.w3.org/TR/REC-xml/). To paraphrase this definition, a valid XML name must begin with a letter, an underscore ('_'), or a colon (':') and can be followed by zero or more NameChar characters (also defined in the XML specification).
- `id` is "NULL" or "VOID" or "GARBAGE".
- `id` contains at least one invalid rule ID character. These characters are: '?', '*', '+', '|', '(', '), '^', '$', '/', ';', '.', '=', '\<', '>', '[', ']', '{', '}', '\\\\', ' ', '\t', '\r', and '\n'.
## Examples
The following example creates a grammar that recognizes the phrase "A nation that has won the World Cup is" followed by the name of a country that has won the World Cup. The example creates a public rule named `WorldCupWinner`. The example then creates two <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule> objects, `ruleEurope` and `ruleSAmerica`, passing in a <xref:System.String> for the rule identifier and an <xref:System.Speech.Recognition.SrgsGrammar.SrgsElement> array containing a <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf> object. Subsequently, the example adds rule references to `ruleEurope` and `ruleSAmerica` from the rule `WorldCupWinner`.
```csharp
public void WorldSoccerWinners ()
{
// Create a grammar from an SRGSDocument, create a new rule
// and set its scope to public.
SrgsDocument srgsGrammar = new SrgsDocument ();
SrgsRule winnerRule = new SrgsRule ("WorldCupWinner");
winnerRule.Scope = SrgsRuleScope.Public;
// Add the introduction.
winnerRule.Elements.Add (new SrgsItem ("A nation that has won the world cup is"));
// Create the rule for the European nations.
SrgsOneOf oneOfEurope = new SrgsOneOf(new SrgsItem[] {new SrgsItem("England"), new SrgsItem("France"), new SrgsItem("Germany"), new SrgsItem("Italy")});
SrgsRule ruleEurope = (new SrgsRule("EuropeanNations", new SrgsElement[] {oneOfEurope}));
// Create the rule for the South American nations.
SrgsOneOf oneOfSAmerica = new SrgsOneOf(new SrgsItem[] {new SrgsItem("Argentina"), new SrgsItem("Brazil"), new SrgsItem("Uruguay")});
SrgsRule ruleSAmerica = (new SrgsRule("SouthAmericanNations", new SrgsElement[] {oneOfSAmerica}));
// Add references to winnerRule for ruleEurope and ruleSAmerica.
winnerRule.Elements.Add(new SrgsOneOf(new SrgsItem[] {(new SrgsItem (new SrgsRuleRef(ruleEurope))), new SrgsItem(new SrgsRuleRef(ruleSAmerica))}));
// Add all the rules to the grammar and make winnerRule
// the root rule of the grammar.
document.Rules.Add(new SrgsRule[] {winnerRule, ruleEurope, ruleSAmerica});
srgsGrammar.Root = winnerRule;
}
```
The created grammar has the following form.
```xml
<grammar version="1.0" xml:lang="en-US" xmlns="http://www.w3.org/2001/06/grammar" root="WorldCupWinner">
<rule id="WorldCupWinner" scope="public">
<item> A nation that has won the world cup is </item>
<one-of>
<item>
<ruleref uri="#EuropeanNations" />
</item>
<item>
<ruleref uri="#SouthAmericanNations" />
</item>
</one-of>
</rule>
<rule id="EuropeanNations">
<one-of>
<item> England </item>
<item> France </item>
<item> Germany </item>
<item> Italy </item>
</one-of>
</rule>
<rule id="SouthAmericanNations">
<one-of>
<item> Argentina </item>
<item> Brazil </item>
<item> Uruguay </item>
</one-of>
</rule>
</grammar>
```
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="id" /> is <see langword="null" />.
<paramref name="elements" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="id" /> is empty.</exception>
<exception cref="T:System.FormatException">
<paramref name="id" /> is not a proper rule identifier.</exception>
<related type="Article" href="https://learn.microsoft.com/previous-versions/office/developer/speech-technologies/hh361680(v%3doffice.14)">Create Grammars Using SrgsGrammar</related>
</Docs>
</Member>
<Member MemberName="Add">
<MemberSignature Language="C#" Value="public void Add (System.Speech.Recognition.SrgsGrammar.SrgsElement element);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Add(class System.Speech.Recognition.SrgsGrammar.SrgsElement element) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Speech.Recognition.SrgsGrammar.SrgsRule.Add(System.Speech.Recognition.SrgsGrammar.SrgsElement)" />
<MemberSignature Language="VB.NET" Value="Public Sub Add (element As SrgsElement)" />
<MemberSignature Language="F#" Value="member this.Add : System.Speech.Recognition.SrgsGrammar.SrgsElement -> unit" Usage="srgsRule.Add element" />
<MemberSignature Language="C++ CLI" Value="public:
 void Add(System::Speech::Recognition::SrgsGrammar::SrgsElement ^ element);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="element" Type="System.Speech.Recognition.SrgsGrammar.SrgsElement" />
</Parameters>
<Docs>
<param name="element">An object that inherits from <see cref="T:System.Speech.Recognition.SrgsGrammar.SrgsElement" /> and specifies what can be recognized.</param>
<summary>Adds an <see cref="T:System.Speech.Recognition.SrgsGrammar.SrgsElement" /> to an <see cref="T:System.Speech.Recognition.SrgsGrammar.SrgsRule" /> object.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Typical additions to an <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule> object include <xref:System.Speech.Recognition.SrgsGrammar.SrgsItem>, <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf>, <xref:System.Speech.Recognition.SrgsGrammar.SrgsRuleRef>, and <xref:System.Speech.Recognition.SrgsGrammar.SrgsToken> objects that specify what speakers can say. A valid rule element must contain at least one piece of recognizable text or one rule reference. See [Create Grammars Using SrgsGrammar](https://docs.microsoft.com/previous-versions/office/developer/speech-technologies/hh361680(v%3doffice.14)) for more information.
An <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule> object may also contain <xref:System.Speech.Recognition.SrgsGrammar.SrgsNameValueTag> and <xref:System.Speech.Recognition.SrgsGrammar.SrgsSemanticInterpretationTag> objects that add semantic values and semantic keys to the rule. The speech recognition engine will return the semantic information, as well as the recognized phrase, when it recognizes the phrase. See [Semantic Interpretation Markup](https://docs.microsoft.com/previous-versions/office/developer/speech-technologies/hh361595(v%3doffice.14)) for more information.
## Examples
The following example creates a grammar that recognizes the phrase "A nation that has won the World Cup is" followed by the name of a country that has won the World Cup. After creating the <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule> object `winnerRule` and giving it the string identifier `WorldCupWinner`, the example uses the <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule.Add%2A> method to append the string "A nation that has won the World Cup is" to the rule. The example then creates two additional rules, `ruleEurope` and `ruleSAmerica`. Again using the <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule.Add%2A> method, the example appends an <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf> object to the `WorldCupWinner` rule that contains rule references to `ruleEurope` and `ruleSAmerica`.
```csharp
// Create an SrgsDocument, create a new rule
// and set its scope to public.
SrgsDocument document = new SrgsDocument();
SrgsRule winnerRule = new SrgsRule("WorldCupWinner");
winnerRule.Scope = SrgsRuleScope.Public;
// Add the introduction.
winnerRule.Elements.Add(new SrgsItem("A nation that has won the world cup is: "));
// Create the rule for the European nations.
SrgsOneOf oneOfEurope = new SrgsOneOf(new SrgsItem[] {new SrgsItem("England"), new SrgsItem("France"), new SrgsItem("Germany"), new SrgsItem("Italy")});
SrgsRule ruleEurope = (new SrgsRule("EuropeanNations", new SrgsElement[] {oneOfEurope}));
// Create the rule for the South American nations.
SrgsOneOf oneOfSAmerica = new SrgsOneOf(new SrgsItem[] {new SrgsItem("Argentina"), new SrgsItem("Brazil"), new SrgsItem("Uruguay")});
SrgsRule ruleSAmerica = (new SrgsRule("SouthAmericanNations", new SrgsElement[] {oneOfSAmerica}));
// Add references to winnerRule for ruleEurope and ruleSAmerica.
winnerRule.Elements.Add(new SrgsOneOf(new SrgsItem[] {(new SrgsItem (new SrgsRuleRef(ruleEurope))), new SrgsItem(new SrgsRuleRef(ruleSAmerica))}));
// Add all the rules to the document and make winnerRule
// the root rule of the document.
document.Rules.Add(new SrgsRule[] {winnerRule, ruleEurope, ruleSAmerica});
document.Root = winnerRule;
```
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="element" /> is <see langword="null" />.</exception>
<related type="Article" href="https://learn.microsoft.com/previous-versions/office/developer/speech-technologies/hh361680(v%3doffice.14)">Create Grammars Using SrgsGrammar</related>
<related type="Article" href="https://learn.microsoft.com/previous-versions/office/developer/speech-technologies/hh361595(v%3doffice.14)">Semantic Interpretation Markup</related>
</Docs>
</Member>
<Member MemberName="BaseClass">
<MemberSignature Language="C#" Value="public string BaseClass { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance string BaseClass" />
<MemberSignature Language="DocId" Value="P:System.Speech.Recognition.SrgsGrammar.SrgsRule.BaseClass" />
<MemberSignature Language="VB.NET" Value="Public Property BaseClass As String" />
<MemberSignature Language="F#" Value="member this.BaseClass : string with get, set" Usage="System.Speech.Recognition.SrgsGrammar.SrgsRule.BaseClass" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ BaseClass { System::String ^ get(); void set(System::String ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>This property is not currently supported.</summary>
<value>Not supported.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Elements">
<MemberSignature Language="C#" Value="public System.Collections.ObjectModel.Collection<System.Speech.Recognition.SrgsGrammar.SrgsElement> Elements { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Collections.ObjectModel.Collection`1<class System.Speech.Recognition.SrgsGrammar.SrgsElement> Elements" />
<MemberSignature Language="DocId" Value="P:System.Speech.Recognition.SrgsGrammar.SrgsRule.Elements" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property Elements As Collection(Of SrgsElement)" />
<MemberSignature Language="F#" Value="member this.Elements : System.Collections.ObjectModel.Collection<System.Speech.Recognition.SrgsGrammar.SrgsElement>" Usage="System.Speech.Recognition.SrgsGrammar.SrgsRule.Elements" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::Collections::ObjectModel::Collection<System::Speech::Recognition::SrgsGrammar::SrgsElement ^> ^ Elements { System::Collections::ObjectModel::Collection<System::Speech::Recognition::SrgsGrammar::SrgsElement ^> ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Collections.ObjectModel.Collection<System.Speech.Recognition.SrgsGrammar.SrgsElement></ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the collection of <see cref="T:System.Speech.Recognition.SrgsGrammar.SrgsElement" /> objects in the <see cref="T:System.Speech.Recognition.SrgsGrammar.SrgsRule" /> instance.</summary>
<value>The collection of elements in the rule.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The elements in an <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule> object can consist of <xref:System.Speech.Recognition.SrgsGrammar.SrgsItem>, <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf>, <xref:System.Speech.Recognition.SrgsGrammar.SrgsRuleRef>, <xref:System.Speech.Recognition.SrgsGrammar.SrgsToken>, <xref:System.Speech.Recognition.SrgsGrammar.SrgsNameValueTag>, and <xref:System.Speech.Recognition.SrgsGrammar.SrgsSemanticInterpretationTag> objects.
]]></format>
</remarks>
<related type="Article" href="https://learn.microsoft.com/previous-versions/office/developer/speech-technologies/hh361680(v%3doffice.14)">Create Grammars Using SrgsGrammar</related>
</Docs>
</Member>
<Member MemberName="Id">
<MemberSignature Language="C#" Value="public string Id { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Id" />
<MemberSignature Language="DocId" Value="P:System.Speech.Recognition.SrgsGrammar.SrgsRule.Id" />
<MemberSignature Language="VB.NET" Value="Public Property Id As String" />
<MemberSignature Language="F#" Value="member this.Id : string with get, set" Usage="System.Speech.Recognition.SrgsGrammar.SrgsRule.Id" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ Id { System::String ^ get(); void set(System::String ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the identifier for the rule.</summary>
<value>The identifier for the rule.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The identifier for a rule is a string that contains the name of the rule.
A value used to set <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule.Id%2A> must adhere to the following rules:
- The value must be a valid XML name, as defined in [Extensible Markup Language (XML) 1.0 (Fifth Edition)](https://www.w3.org/TR/REC-xml/). To paraphrase this definition, a valid XML name must begin with a letter, an underscore ('_'), or a colon (':') and can be followed by zero or more NameChar characters (also defined in the XML specification).
- The value can be "NULL" or "VOID" or "GARBAGE".
- The value cannot contain any invalid rule ID character. These characters are: '?', '*', '+', '|', '(', '), '^', '$', '/', ';', '.', '=', '\<', '>', '[', ']', '{', '}', '\\\\', ' ', '\t', '\r', and '\n'.
]]></format>
</remarks>
<exception cref="T:System.FormatException">An attempt is made to set <see cref="P:System.Speech.Recognition.SrgsGrammar.SrgsRule.Id" /> to an invalid value.</exception>
</Docs>
</Member>
<Member MemberName="OnError">
<MemberSignature Language="C#" Value="public string OnError { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance string OnError" />
<MemberSignature Language="DocId" Value="P:System.Speech.Recognition.SrgsGrammar.SrgsRule.OnError" />
<MemberSignature Language="VB.NET" Value="Public Property OnError As String" />
<MemberSignature Language="F#" Value="member this.OnError : string with get, set" Usage="System.Speech.Recognition.SrgsGrammar.SrgsRule.OnError" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ OnError { System::String ^ get(); void set(System::String ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>This property is not currently supported.</summary>
<value>Not supported.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="OnInit">
<MemberSignature Language="C#" Value="public string OnInit { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance string OnInit" />
<MemberSignature Language="DocId" Value="P:System.Speech.Recognition.SrgsGrammar.SrgsRule.OnInit" />
<MemberSignature Language="VB.NET" Value="Public Property OnInit As String" />
<MemberSignature Language="F#" Value="member this.OnInit : string with get, set" Usage="System.Speech.Recognition.SrgsGrammar.SrgsRule.OnInit" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ OnInit { System::String ^ get(); void set(System::String ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>This property is not currently supported.</summary>
<value>Not supported.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="OnParse">
<MemberSignature Language="C#" Value="public string OnParse { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance string OnParse" />
<MemberSignature Language="DocId" Value="P:System.Speech.Recognition.SrgsGrammar.SrgsRule.OnParse" />
<MemberSignature Language="VB.NET" Value="Public Property OnParse As String" />
<MemberSignature Language="F#" Value="member this.OnParse : string with get, set" Usage="System.Speech.Recognition.SrgsGrammar.SrgsRule.OnParse" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ OnParse { System::String ^ get(); void set(System::String ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>This property is not currently supported.</summary>
<value>Not supported.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="OnRecognition">
<MemberSignature Language="C#" Value="public string OnRecognition { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance string OnRecognition" />
<MemberSignature Language="DocId" Value="P:System.Speech.Recognition.SrgsGrammar.SrgsRule.OnRecognition" />
<MemberSignature Language="VB.NET" Value="Public Property OnRecognition As String" />
<MemberSignature Language="F#" Value="member this.OnRecognition : string with get, set" Usage="System.Speech.Recognition.SrgsGrammar.SrgsRule.OnRecognition" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ OnRecognition { System::String ^ get(); void set(System::String ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>This property is not currently supported.</summary>
<value>Not supported.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Scope">
<MemberSignature Language="C#" Value="public System.Speech.Recognition.SrgsGrammar.SrgsRuleScope Scope { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.Speech.Recognition.SrgsGrammar.SrgsRuleScope Scope" />
<MemberSignature Language="DocId" Value="P:System.Speech.Recognition.SrgsGrammar.SrgsRule.Scope" />
<MemberSignature Language="VB.NET" Value="Public Property Scope As SrgsRuleScope" />
<MemberSignature Language="F#" Value="member this.Scope : System.Speech.Recognition.SrgsGrammar.SrgsRuleScope with get, set" Usage="System.Speech.Recognition.SrgsGrammar.SrgsRule.Scope" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::Speech::Recognition::SrgsGrammar::SrgsRuleScope Scope { System::Speech::Recognition::SrgsGrammar::SrgsRuleScope get(); void set(System::Speech::Recognition::SrgsGrammar::SrgsRuleScope value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Speech.Recognition.SrgsGrammar.SrgsRuleScope</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets whether a rule can be activated for recognition and when the rule can be referenced by other rules.</summary>
<value>A value the sets the scope for the rule.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The default value for scope is `Private`. A private rule can only be activated for recognition by a rule reference from the root rule in its containing grammar or from another rule that is referenced from the root rule. A private rule cannot be referenced by an external grammar, unless the private rule is declared as the root rule of its containing grammar.
If its scope is set to `Public`, an <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule> object can be activated for recognition by a reference from a <xref:System.Speech.Recognition.SrgsGrammar.SrgsRuleRef> object in the containing grammar or from a rule in an external grammar.
## Examples
The following example creates a grammar that recognizes the phrase "A nation that has won the World Cup is" followed by the name of a country that has won the World Cup. It creates a public rule named `WorldCupWinner` and sets the scope of that rule to Public.
```csharp
// Create an SrgsDocument, create a new rule and set its scope to public.
SrgsDocument document = new SrgsDocument();
SrgsRule winnerRule = new SrgsRule("WorldCupWinner");
winnerRule.Scope = SrgsRuleScope.Public;
// Add the introduction.
winnerRule.Elements.Add(new SrgsItem("A nation that has won the world cup is: "));
// Create the rule for the European nations.
SrgsOneOf oneOfEurope = new SrgsOneOf(new SrgsItem[] {new SrgsItem("England"), new SrgsItem("France"), new SrgsItem("Germany"), new SrgsItem("Italy")});
SrgsRule ruleEurope = (new SrgsRule("EuropeanNations", new SrgsElement[] {oneOfEurope}));
// Create the rule for the South American nations.
SrgsOneOf oneOfSAmerica = new SrgsOneOf(new SrgsItem[] {new SrgsItem("Argentina"), new SrgsItem("Brazil"), new SrgsItem("Uruguay")});
SrgsRule ruleSAmerica = (new SrgsRule("SouthAmericanNations", new SrgsElement[] {oneOfSAmerica}));
// Add references to winnerRule for ruleEurope and ruleSAmerica.
winnerRule.Elements.Add(new SrgsOneOf(new SrgsItem[] {(new SrgsItem (new SrgsRuleRef(ruleEurope)), new SrgsItem(new SrgsRuleRef(ruleSAmerica)})));
// Add all the rules to the document and make winnerRule
// the root rule of the document.
document.Rules.Add(new SrgsRule[] {winnerRule, ruleEurope, ruleSAmerica});
document.Root = winnerRule;
```
The created grammar has the following form.
```xml
<grammar version="1.0" xml:lang="en-US" xmlns="http://www.w3.org/2001/06/grammar" root="WorldCupWinner">
<rule id="WorldCupWinner" scope="public">
<item> A nation that has won the world cup is </item>
<one-of>
<item>
<ruleref uri="#EuropeanNations" />
</item>
<item>
<ruleref uri="#SouthAmericanNations" />
</item>
</one-of>
</rule>
<rule id="EuropeanNations">
<one-of>
<item> England< /item>
<item> France </item>
<item> Germany </item>
<item> Italy </item>
</one-of>
</rule>
<rule id="SouthAmericanNations">
<one-of>
<item> Argentina </item>
<item> Brazil </item>
<item> Uruguay </item>
</one-of>
</rule>
</grammar>
```
]]></format>
</remarks>
<related type="Article" href="https://learn.microsoft.com/previous-versions/office/developer/speech-technologies/hh361680(v%3doffice.14)">Create Grammars Using SrgsGrammar</related>
<related type="ExternalDocumentation" href="https://go.microsoft.com/fwlink/?linkid=15143&clcid=0x409">Speech Recognition Grammar Specification Version 1.0</related>
</Docs>
</Member>
<Member MemberName="Script">
<MemberSignature Language="C#" Value="public string Script { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Script" />
<MemberSignature Language="DocId" Value="P:System.Speech.Recognition.SrgsGrammar.SrgsRule.Script" />
<MemberSignature Language="VB.NET" Value="Public Property Script As String" />
<MemberSignature Language="F#" Value="member this.Script : string with get, set" Usage="System.Speech.Recognition.SrgsGrammar.SrgsRule.Script" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ Script { System::String ^ get(); void set(System::String ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>This property is not currently supported.</summary>
<value>Not supported.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>