File: rsWalkthrough.htm

package info (click to toggle)
office2003-schemas 1.0%2Bds-1
  • links: PTS, VCS
  • area: non-free
  • in suites: bookworm, forky, sid, trixie
  • size: 42,304 kB
  • sloc: javascript: 2,429; makefile: 29
file content (880 lines) | stat: -rw-r--r-- 58,063 bytes parent folder | download
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
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
<html dir="ltr"><head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META HTTP-EQUIV="assetid" CONTENT="HV01091697"><META NAME="lcid" CONTENT="1033"><title>Research Service Sample Walkthrough</title><link rel="stylesheet" type="text/css" href="office10.css"><script type="text/javascript" language="Javascript" src="ExpCollapse.js"></script><script type="text/javascript" language="JavaScript" src="inline.js"></script></head><body><p id="ExpandAllLine" class="ExpFav"><a href="#" onclick="ExpandAll()" onkeypress="ExpandAll()" class="DropDown"><img id="picHeader" border="0" src="expandtri.gif" alt="Show All"><span id="ExpandAll">Show All</span></a></p><h1>Research Service Sample Walkthrough</h1><p>The <a href="rsSamplesIBuySpy.htm" id="HV01082287" lcid=" ">IBuySpy Sample</a> included with this SDK is a good example of a research service written with Microsoft® Visual Basic® .NET that observes the coding practices suggested in <a href="rsResearchWS.htm" id="HV01084670" lcid=" ">Building a Research Web Service</a>. This sample not only displays formatted content in the <b class="bterm">Research</b> task pane from the<b class="bterm"> Response.Content</b> and the <b class="bterm">Response.Form</b> namespaces, but it also enhances the query results with custom actions implemented in a smart tag DLL. In this topic, we take a look at the IBuySpy sample and some of the techniques it uses to achieve powerful results in the <b class="bterm">Research</b> task pane.</p><p><b>Important</b>  Since the IBuySpy sample includes complete source code, this topic includes only limited excerpts from the code. The excerpts that are shown may omit variable declarations, error handling, and other important sections of the code. We suggest that you  set up the IBuySpy sample and open it in Microsoft Visual Studio® .NET so that you can follow along during this walkthrough. Note that the <code>Utils</code> class referenced in the code samples in this topic is a helper class of support functions in the IBuySpy sample.</p><p><a href="#" class="DropDown" onclick="Outline2()" onkeypress="Outline2()"><img border="0" src="blueup.gif" alt="Show"><b class="bterm">Registration</b> method</a></p><div id="ExpCol" class="collapsed" border="0"><p>When a client computer calls the <b class="bterm">Registration</b> Web method of the IBuySpy sample, the <b class="bterm">Registration</b> method takes the following steps to assemble the registration response packet:<ol><li>The <b class="bterm">Registration</b> method loads the contents of a saved XML template file (RegistrationResponse.xml)  into a new <b class="bterm">XMLDocument</b>.<pre><code>Dim xdResponse As New XmlDocument
Try
    xdResponse.Load(Utils.GetCurrentPath &amp; _
         "\xml\RegistrationResponse.xml")
    Dim nsm As New XmlNamespaceManager(xdResponse.NameTable)
    nsm.AddNamespace("ns", _
        "urn:Microsoft.Search.Registration.Response")
    ...
</code></pre> This template file contains a registration response consisting largely of empty tags. The empty template file looks like this:<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;ProviderUpdate xmlns="urn:Microsoft.Search.Registration.Response"&gt;
    &lt;Status&gt;SUCCESS&lt;/Status&gt;
    &lt;Providers&gt;
        &lt;Provider&gt;
            &lt;Message/&gt;
            &lt;Id&gt;{5A1AAF54-87F0-4f1d-A2D4-AB3E5D080DE1}&lt;/Id&gt;
            &lt;Name/&gt;
            &lt;QueryPath/&gt;
            &lt;RegistrationPath/&gt;
            &lt;Type&gt;SOAP&lt;/Type&gt;
            &lt;Services&gt;
                &lt;Service&gt;
                    &lt;Id&gt;{1698075D-E2F5-4254-87B2-7FC9E9AB0780}&lt;/Id&gt;
                    &lt;Name/&gt;
                    &lt;Description/&gt;
                    &lt;Copyright&gt;
                        All content Copyright (c) 2003.
                    &lt;/Copyright&gt;
                    &lt;Display&gt;On&lt;/Display&gt;
                    &lt;Category/&gt;
                &lt;/Service&gt;
            &lt;/Services&gt;
        &lt;/Provider&gt;
    &lt;/Providers&gt;
&lt;/ProviderUpdate&gt;
</code></pre></li><li>The <b class="bterm">Registration</b> method uses an <b class="bterm">OleDbDataReader</b> to load the values for the registration response from the ResearchPane table of the sample's DemoData.mdb Microsoft Jet database.<pre><code>Dim oDR As OleDbDataReader = Utils.GetData_RegistrationInformation()
oDR.Read()
</code></pre></li><li>The <b class="bterm">Registration</b> method moves through the list of values returned by the <b class="bterm">OleDbDataReader</b> and uses the <b class="bterm">SelectSingleNode</b> method of the <b class="bterm">XmlDocument</b> to locate the appropriate node for each value and copy it from the  <b class="bterm">OleDbDataReader</b> column to the <b class="bterm">InnerText</b> property of the node.<pre><code>With xdResponse
    .SelectSingleNode("//ns:Message", nsm).InnerText = _
        oDR("ProviderMessage")
    ...
    .SelectSingleNode("//ns:Service/ns:Category", nsm).InnerText = _
        oDR("ServiceCategory")
End With
</code></pre></li><li>The <b class="bterm">Registration</b> method returns the string contents of the completed <b class="bterm">XmlDocument</b> to the client computer.<pre><code>Return xdResponse.InnerXml.ToString
</code></pre>The completed registration response template now looks like this:<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;ProviderUpdate xmlns="urn:Microsoft.Search.Registration.Response"&gt;
    &lt;Status&gt;SUCCESS&lt;/Status&gt;
    &lt;Providers&gt;
        &lt;Provider&gt;
            &lt;Message&gt;
                Congratulations ... our broad product line.
            &lt;/Message&gt;
            &lt;Id&gt;{5A1AAF54-87F0-4f1d-A2D4-AB3E5D080DE1}&lt;/Id&gt;
            &lt;Name&gt;IBuySpyStore.com Research Pane&lt;/Name&gt;
            &lt;QueryPath&gt;
                http://servername/IBuySpyResearchPane/Query.asmx
            &lt;/QueryPath&gt;
            &lt;RegistrationPath&gt;
                http://servername/IBuySpyResearchPane/
                Registration.asmx
            &lt;/RegistrationPath&gt;
            &lt;Type&gt;SOAP&lt;/Type&gt;
            &lt;Services&gt;
                &lt;Service&gt;
                    &lt;Id&gt;
                        {1698075D-E2F5-4254-87B2-7FC9E9AB0780}
                    &lt;/Id&gt;
                    &lt;Name&gt;IBuySpy.com Product Information&lt;/Name&gt;
                    &lt;Description&gt;
                        Congratulations ... our broad product line.
                    &lt;/Description&gt;
                    &lt;Copyright&gt;
                        All content Copyright (c) 2003.
                    &lt;/Copyright&gt;
                    &lt;Display&gt;On&lt;/Display&gt;
                    &lt;Category&gt;INTRANET_GENERAL&lt;/Category&gt;
                &lt;/Service&gt;
            &lt;/Services&gt;
        &lt;/Provider&gt;
    &lt;/Providers&gt;
&lt;/ProviderUpdate&gt;
</code></pre></li></ol></p></div><p><a href="#" class="DropDown" onclick="Outline2()" onkeypress="Outline2()"><img border="0" src="blueup.gif" alt="Show">  <b class="bterm">Query</b> method: Introduction</a></p><div id="ExpCol" class="collapsed" border="0"><p>When a client computer calls the <b class="bterm">Query</b> Web method of the IBuySpy sample, the <b class="bterm">Query</b> method takes the following steps to begin processing the query response packet:<ol><li>First, the method loads the contents of the input argument (<code>queryXml</code>) into a  new <b class="bterm">XmlDocument</b> and references the appropriate namespaces. (The sample code does not reference the <b class="bterm">Microsoft.Search.Query.Office.Keywords</b> namespace since it does not use the contents of the <b class="bterm">Keywords</b> section of the query packet.)<pre><code>Dim requestXml As New XmlDocument()
...
requestXml.LoadXml(queryXml)
Dim nsmRequest As New XmlNamespaceManager(requestXml.NameTable)
With nsmRequest
    .AddNamespace("ns", "urn:Microsoft.Search.Query")
    .AddNamespace("sp", _
        "urn:Microsoft.Search.Office.ServiceParameters")
    .AddNamespace("oc", "urn:Microsoft.Search.Query.Office.Context")
End With
</code></pre></li><li>Next, the <b class="bterm">Query</b> method extracts the text of the user's query and the name of the Microsoft Office host application.<pre><code>queryTerm = requestXml.SelectSingleNode("//ns:QueryText", _
    nsmRequest).InnerText
applicationName = requestXml.SelectSingleNode("//oc:Name", _
    nsmRequest).InnerText
</code></pre></li><li>Then the <b class="bterm">Query</b> method loads the contents of a saved XML template file (ResponsePacketWrapper.xml)  into a new <b class="bterm">XmlDocument</b>.<pre><code>responseWrapper.Load(Utils.GetCurrentPath &amp; _
    "\xml\ResponsePacketWrapper.xml")
Dim nsmResponseWrapper As New _
    XmlNamespaceManager(responseWrapper.NameTable)
nsmResponseWrapper.AddNamespace( _
    "ns", "urn:Microsoft.Search.Response")
</code></pre>This template file contains a query response consisting largely of empty tags. The rest of the code in the <b class="bterm">Query</b> method and in its supporting methods fills in the <b class="bterm">Results</b> element of the template. The empty template file looks like this:<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;ResponsePacket revision="1" xmlns="urn:Microsoft.Search.Response"&gt;
    &lt;Response domain="{1698075D-E2F5-4254-87B2-7FC9E9AB0780}"&gt;
        &lt;QueryId&gt;{8E823A74-053D-4434-A67B-D1CD050B3349}&lt;/QueryId&gt;
        &lt;Range&gt;
            &lt;Results&gt;            
            &lt;/Results&gt;
        &lt;/Range&gt;
        &lt;Status&gt;SUCCESS&lt;/Status&gt;
    &lt;/Response&gt;
&lt;/ResponsePacket&gt;
</code></pre></li><li>Finally, the <b class="bterm">Query</b> method uses an <code>If/ElseIf</code> block to determine what type of query the user has submitted, and to call the appropriate one of six private methods (whose names begin with the <code>Response_</code> prefix) that process specific query types such as Product Details and Products by Category. After the helper method returns its results, the <b class="bterm">Query</b> method adds these results to the query response template and returns the string contents of the completed <b class="bterm">XmlDocument</b> to the client computer.<pre><code>responseWrapper.SelectSingleNode("//ns:Results", _
    nsmResponseWrapper).InnerXml = responseBody.ToString

Return responseWrapper.InnerXml.ToString
</code></pre></li></ol></p></div><p>In the following sections, we take a look at six different query scenarios in the IBuySpy sample. For each query scenario, we examine:<ol><li>The steps to follow in Microsoft Office Word 2003 to launch the query.</li><li>The visual results of the query in the <b class="bterm">Research</b> task pane.</li><li>The important portions of the XML query request packet sent from the <b class="bterm">Research</b> task pane to the research service.</li><li>The important portions of the research service code that processes the query.</li><li>The important portions of the XML query response packet returned by the research service to the <b class="bterm">Research</b> task pane.</li></ol></p><p><a href="#" class="DropDown" onclick="Outline2()" onkeypress="Outline2()"><img border="0" src="blueup.gif" alt="Show"><b class="bterm">Query</b> method: Keyword search (no results found)</a></p><div id="ExpCol" class="collapsed" border="0"><p>This section demonstrates a keyword search query that does not return results and calls the <code>Response_NoResults</code> private method in the IBuySpy sample.</p><ol><li><b class="bterm">Steps</b>. To view the results of a keyword search that does not return results:<ol><li> Open CustomerLetter.doc (included with the IBuySpy sample) in Microsoft Office Word 2003.</li><li>Open the <b class="bterm">Research</b> task pane and select the IBuySpy.com Product Information service to search.</li><li>While holding down the ALT key, click a word in the body of the letter that is not likely to produce product database results, such as "customers."</li></ol></li><li><b class="bterm">Visual Results</b>. This query displays the following results in the <b class="bterm">Research</b> task pane:<p><img border="0" src="../img/rsimgWalkthrough1.gif" alt="The results of a keyword search (no results found) query in the Research task pane"></p><p class="ac">Figure 1. The results of a keyword search (no results found) query in the <b class="bterm">Research</b> task pane</p></li><li><b class="bterm">Query Request</b>. Here is the complete text of the query request sent to the IBuySpy.com Product Information research service. (In subsequent sections, we will show only important portions of the query packet.) The query text consists of the word "customers."<pre><code>&lt;QueryPacket xmlns='urn:Microsoft.Search.Query' 
    revision='1' build='(11.0.5606)' &gt;
    &lt;Query domain='{1698075D-E2F5-4254-87B2-7FC9E9AB0780}'&gt;
        &lt;QueryId&gt;{D07E5132-4981-4D74-AE3D-BE7280BB5CE2}&lt;/QueryId&gt;
        &lt;OriginatorId&gt;
            {F6FF7BE0-F39C-4ddc-A7D0-09A4C6C647A5}
        &lt;/OriginatorId&gt;
        &lt;SupportedFormats&gt;
            &lt;Format revision='1'&gt;
                urn:Microsoft.Search.Response.Document:Document
            &lt;/Format&gt;
            &lt;Format revision='1'&gt;
                urn:Microsoft.Search.Response.Content:Content
            &lt;/Format&gt;
            &lt;Format revision='1'&gt;
                urn:Microsoft.Search.Response.Form:Form
            &lt;/Format&gt;
        &lt;/SupportedFormats&gt;
        &lt;Context&gt;
            &lt;QueryText type='STRING' language='en-us' &gt;
                customers
            &lt;/QueryText&gt;
            &lt;LanguagePreference&gt;en-us&lt;/LanguagePreference&gt;
            &lt;Requery&gt;&lt;/Requery&gt;
        &lt;/Context&gt;
        &lt;Range id='result'&gt;&lt;/Range&gt;
        &lt;OfficeContext 
            xmlns='urn:Microsoft.Search.Query.Office.Context' 
            revision='1'&gt;
            &lt;UserPreferences&gt;
                &lt;ParentalControl&gt;false&lt;/ParentalControl&gt;
            &lt;/UserPreferences&gt;
            &lt;ServiceData&gt;&lt;/ServiceData&gt;
            &lt;ApplicationContext&gt;
                &lt;Name&gt;Microsoft Office Word&lt;/Name&gt;
                &lt;Version&gt;(11.0.5606)&lt;/Version&gt;
                &lt;SystemInformation&gt;
                    &lt;SkuLanguage&gt;en-us&lt;/SkuLanguage&gt;
                    &lt;LanguagePack&gt;en-us&lt;/LanguagePack&gt;
                    &lt;InterfaceLanguage&gt;en-us&lt;/InterfaceLanguage&gt;
                    &lt;Location&gt;US&lt;/Location&gt;
                &lt;/SystemInformation&gt;
            &lt;/ApplicationContext&gt;
            &lt;QueryLanguage&gt;en-us&lt;/QueryLanguage&gt;
            &lt;KeyboardLanguage&gt;en-us&lt;/KeyboardLanguage&gt;
        &lt;/OfficeContext&gt;
        &lt;Keywords xmlns='urn:Microsoft.Search.Query.Office.Keywords' 
            revision='1'&gt;
            &lt;QueryText&gt;customers&lt;/QueryText&gt;
            &lt;Keyword&gt;
                &lt;Word&gt;customers&lt;/Word&gt;
            &lt;/Keyword&gt;
        &lt;/Keywords&gt;
    &lt;/Query&gt;
&lt;/QueryPacket&gt;</code></pre></li><li><b class="bterm">Code</b>. The code fails to locate the term "customers" in the IBuySpy product database. However, instead of simply returning an unhelpful "No results found" message to the user, it displays two helpful lists of searchable topics:<ul><li>A hyperlinked list of Product Categories.</li><li>A collapsed, hierarchical list of hyperlinked Products by Category.</li></ul>The following code generates the nested list of Products by Category.  Note that the <b class="bterm">NewQuery</b> element allows the user to request more information by clicking a category or a product. The <b class="bterm">collapsed</b> attribute of the <b class="bterm">Heading</b> element allows you to conserve space while grouping results.<pre><code>With outputXmlWriter
    'Content Heading
    .WriteStartElement("Content", _
    "urn:Microsoft.Search.Response.Content")
...
    .WriteStartElement("Heading")
    .WriteAttributeString("collapsed", "false")
    .WriteElementString("Text", "Products By Category")
    categoryData = Utils.GetData_CategoryList()
    While categoryData.Read
        .WriteStartElement("Heading") 'Category Heading
        .WriteAttributeString("collapsed", "true")
        .WriteElementString("Text", categoryData("CategoryName"))
        productsTopData = _
            Utils.GetData_ProductsTopList(categoryData("CategoryID"))
        While productsTopData.Read
            'New Query to get more product details
            .WriteStartElement("NewQuery")
            .WriteAttributeString("query", _
                productsTopData("ModelNumber"))
            .WriteElementString("Text", _
                productsTopData("ModelNumber") &amp; " - " &amp; _
                    productsTopData("ModelName"))
            .WriteEndElement()
        End While
        .WriteEndElement() 'Category Heading
    End While
    .WriteEndElement() 'Heading
...
    .WriteEndElement() 'Content
    .Flush()
End With
</code></pre></li><li><b class="bterm">Query Response</b>. Here are the important portions of the query response returned  by the IBuySpy.com Product Information research service.<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;ResponsePacket revision="1" xmlns="urn:Microsoft.Search.Response"&gt;
    &lt;Response domain="{1698075D-E2F5-4254-87B2-7FC9E9AB0780}"&gt;
        &lt;QueryId&gt;{8E823A74-053D-4434-A67B-D1CD050B3349}&lt;/QueryId&gt;
        &lt;Range&gt;
            &lt;Results&gt;
                &lt;Content 
                    xmlns="urn:Microsoft.Search.Response.Content"&gt;
                    &lt;P&gt;
                        The search term 
                        &lt;Char bold="true"&gt;customers&lt;/Char&gt; 
                        returned no results. The following is a 
                        sample list of searchable terms:
                    &lt;/P&gt;
                    &lt;Heading collapsed="false"&gt;
                        &lt;Text&gt;Categories&lt;/Text&gt;
                        &lt;NewQuery query="Communications"&gt;
                            &lt;Text&gt;Communications&lt;/Text&gt;
                        &lt;/NewQuery&gt;
                        ...
                        &lt;NewQuery query="Travel"&gt;
                            &lt;Text&gt;Travel&lt;/Text&gt;
                        &lt;/NewQuery&gt;
                    &lt;/Heading&gt;
                    &lt;Heading collapsed="false"&gt;
                        &lt;Text&gt;Products By Category&lt;/Text&gt;
                        &lt;Heading collapsed="true"&gt;
                            &lt;Text&gt;Communications&lt;/Text&gt;
                            &lt;NewQuery query="RED1"&gt;
                                &lt;Text&gt;
                                    RED1 - Communications Device
                                &lt;/Text&gt;
                            &lt;/NewQuery&gt;
                            ...
                            &lt;NewQuery query="LK4TLNT"&gt;
                                &lt;Text&gt;
                                    LK4TLNT - Persuasive Pencil
                                &lt;/Text&gt;
                            &lt;/NewQuery&gt;
                        &lt;/Heading&gt;
                        ...
                        &lt;Heading collapsed="true"&gt;
                            &lt;Text&gt;Travel&lt;/Text&gt;
                            &lt;NewQuery query="LNGWADN"&gt;
                                &lt;Text&gt;LNGWADN - Escape Cord&lt;/Text&gt;
                            &lt;/NewQuery&gt;
                            ...
                            &lt;NewQuery query="WRLD00"&gt;
                                &lt;Text&gt;
                                    WRLD00 - Global 
                                    Navigational System
                                &lt;/Text&gt;
                            &lt;/NewQuery&gt;
                        &lt;/Heading&gt;
                    &lt;/Heading&gt;
                    &lt;NewQuery query="Advanced Product Search"&gt;
                        &lt;Text&gt;Advanced product search ...&lt;/Text&gt;
                    &lt;/NewQuery&gt;
                    &lt;HorizontalRule /&gt;
                    &lt;P&gt;
                        &lt;Char bold="true"&gt;
                            Powered by IBuySpy.com!
                        &lt;/Char&gt;
                    &lt;/P&gt;
                    &lt;P&gt;Congratulations ... at www.IBuySpy.com.&lt;/P&gt;
                &lt;/Content&gt;
            &lt;/Results&gt;
        &lt;/Range&gt;
        &lt;Status&gt;SUCCESS&lt;/Status&gt;
    &lt;/Response&gt;
&lt;/ResponsePacket&gt;</code></pre></li></ol></div><p><a href="#" class="DropDown" onclick="Outline2()" onkeypress="Outline2()"><img border="0" src="blueup.gif" alt="Show"><b class="bterm">Query</b> method: Products by Category</a></p><div id="ExpCol" class="collapsed" border="0"><p>This section demonstrates a Products by Category query and calls the <code>Response_CategoryListAsForm</code> and the <code>Response_ProductSummaryForCategory</code> private methods in the IBuySpy sample.</p><ol><li><b class="bterm">Steps</b>. To view the results of a Products by Category search:<ol><li>Complete the preceding steps for the keyword search (no results found).</li><li>Click one of the hyperlinked categories, such as "Protection," displayed in the <b class="bterm">Research</b> task pane.</li></ol></li><li><b class="bterm">Visual Results</b>. This query displays the following results in the <b class="bterm">Research</b> task pane:<p><img border="0" src="../img/rsimgWalkthrough2.gif" alt="The results of a Products by Category query in the Research task pane"></p><p class="ac">Figure 2. The results of a Products by Category query in the <b class="bterm">Research</b> task pane</p></li><li><b class="bterm">Query Request</b>. Here is the variable content from the query request sent to the IBuySpy.com Product Information research service. The query text consists of the category name, "Protection," from the <b class="bterm">NewQuery</b> element that we clicked.<pre><code>&lt;Context&gt;
    &lt;QueryText type='STRING' language='en-us' &gt;Protection&lt;/QueryText&gt;
    ...
&lt;/Context&gt;
...
&lt;Keywords 
    xmlns='urn:Microsoft.Search.Query.Office.Keywords' revision='1'&gt;
    &lt;QueryText&gt;Protection&lt;/QueryText&gt;
    &lt;Keyword&gt;
        &lt;Word&gt;Protection&lt;/Word&gt;
    &lt;/Keyword&gt;
&lt;/Keywords&gt;
</code></pre></li><li><b class="bterm">Code</b>. The following code from the <code>Response_CategoryListAsForm</code> method generates the drop-down list of Product Categories at the top of the results by using elements from the <b class="bterm">Microsoft.Search.Response.Form</b> namespace:<pre><code>With outputXmlWriter
    'Form Heading
    .WriteStartElement("Form", "urn:Microsoft.Search.Response.Form")

    'Root Listbox 
    .WriteStartElement("Listbox")
    .WriteAttributeString("dropDown", "true")
    .WriteAttributeString("id", "ProductCategoryRequery")
    .WriteAttributeString("action", "requery")
    .WriteElementString("Text", _
        "Select a different product category: ")

    'Each category is now added to the list box
    categoryListData = Utils.GetData_CategoryList()
    While categoryListData.Read
        .WriteStartElement("Option")
        .WriteAttributeString("id", categoryListData("CategoryName"))
        If UCase(categoryListData("CategoryName")) = _
            UCase(queryTerm) Then
            'Default to the currently selected Category
            .WriteAttributeString("selected", "true")
        End If
        .WriteElementString("Text", categoryListData("CategoryName"))
        .WriteEndElement()
    End While

    .WriteEndElement() 'Listbox
    .WriteEndElement() 'Form
...
End With
</code></pre>Next, the <b class="bterm">Response_ProductSummaryForCategory</b> method generates a title and description for each product, its unit cost, a <b class="bterm">NewQuery</b> element to request additional details, and the <b class="bterm">Insert</b> and <b class="bterm">Copy</b> actions for the actions menu, by using elements from the <b class="bterm">Microsoft.Search.Response.Content</b> namespace.<pre><code>With outputXmlWriter
    'Content Heading
    .WriteStartElement("Content", _
        "urn:Microsoft.Search.Response.Content")
    .WriteElementString("HorizontalRule", "")
...
    While productsData.Read
        'Product Heading
        .WriteStartElement("Heading")
        .WriteAttributeString("collapsible", "true")

        'Product Name
        .WriteElementString("Text", productsData("ModelName"))

        'Product Details
        .WriteElementString("P", productsData("Description"))
        .WriteStartElement("P")
        .WriteStartElement("Char")
        .WriteAttributeString("bold", "true")
        .WriteString("Product Price: ")
        .WriteEndElement()
        .WriteElementString("Char", _
            Format(productsData("UnitCost"), "Currency"))
        .WriteEndElement() 'P

        'New Query to get more product details
        .WriteStartElement("NewQuery")
        .WriteAttributeString("query", productsData("ModelNumber"))
        .WriteElementString("Text", "Product Details ...")
        .WriteEndElement()

        'Button with Actions
        .WriteStartElement("Actions")
        .WriteStartElement("Insert")
        .WriteElementString("Text", "Insert Summary")
        .WriteEndElement() 'Insert
        .WriteStartElement("Copy")
        .WriteElementString("Text", "Copy Summary")
        .WriteEndElement() 'Copy
        .WriteElementString("Data", productsData("ModelName") &amp; _
            " - " &amp; productsData("Description") &amp; _
            " (Product Price: " &amp; Format(productsData("UnitCost"), _
            "Currency") &amp; ")")
        .WriteEndElement() 'Actions

        .WriteEndElement() 'Product Heading
    End While

...
    .WriteEndElement() 'Content
    .Flush()

End With
</code></pre></li><li><b class="bterm">Query Response</b>. Here are the important portions of  the query response returned  by the IBuySpy.com Product Information research service. <pre><code>&lt;Range&gt;
    &lt;Results&gt;
        &lt;Form xmlns="urn:Microsoft.Search.Response.Form"&gt;
            &lt;Listbox dropDown="true" id="ProductCategoryRequery" 
                action="requery"&gt;
                &lt;Text&gt;Select a different product category: &lt;/Text&gt;
                &lt;Option id="Communications"&gt;
                    &lt;Text&gt;Communications&lt;/Text&gt;
                &lt;/Option&gt;
                ...
                &lt;Option id="Travel"
                    &gt;&lt;Text&gt;Travel&lt;/Text&gt;
                &lt;/Option&gt;
            &lt;/Listbox&gt;
        &lt;/Form&gt;
        &lt;Content xmlns="urn:Microsoft.Search.Response.Content"&gt;
            &lt;NewQuery query="Advanced Product Search"&gt;
                &lt;Text&gt;Advanced product search ...&lt;/Text&gt;
            &lt;/NewQuery&gt;
        &lt;/Content&gt;
        &lt;Content xmlns="urn:Microsoft.Search.Response.Content"&gt;
            &lt;HorizontalRule /&gt;
            &lt;P&gt;
                &lt;Char bold="true" italic="true"&gt;
                    Products for category PROTECTION
                &lt;/Char&gt;
            &lt;/P&gt;
            &lt;Heading collapsed="true"&gt;
                &lt;Heading collapsible="true"&gt;
                    &lt;Text&gt;Bullet Proof Facial Tissue&lt;/Text&gt;
                    &lt;P&gt;Being a spy ... stop penetration.&lt;/P&gt;
                    &lt;P&gt;
                        &lt;Char bold="true"&gt;Product Price: &lt;/Char&gt;
                        &lt;Char&gt;$79.99&lt;/Char&gt;
                    &lt;/P&gt;
                    &lt;NewQuery query="BSUR2DUC"&gt;
                        &lt;Text&gt;Product Details ...&lt;/Text&gt;
                    &lt;/NewQuery&gt;
                    &lt;Actions&gt;
                        &lt;Insert&gt;
                            &lt;Text&gt;Insert Summary&lt;/Text&gt;
                        &lt;/Insert&gt;
                        &lt;Copy&gt;
                            &lt;Text&gt;Copy Summary&lt;/Text&gt;
                        &lt;/Copy&gt;
                        &lt;Data&gt;
                            Bullet Proof Facial Tissue ... 
                            (Product Price: $79.99)
                        &lt;/Data&gt;
                    &lt;/Actions&gt;
                &lt;/Heading&gt;
                ...
            &lt;/Heading&gt;
        &lt;/Content&gt;
    &lt;/Results&gt;
&lt;/Range&gt;</code></pre></li></ol></div><p><a href="#" class="DropDown" onclick="Outline2()" onkeypress="Outline2()"><img border="0" src="blueup.gif" alt="Show"><b class="bterm">Query</b> method: Keyword search (results found)</a></p><div id="ExpCol" class="collapsed" border="0"><p>This section demonstrates a keyword search query that returns results and calls the <code>Response_ProductKeywordSearch</code> private method in the IBuySpy sample.</p><ol><li><b class="bterm">Steps</b>. To view the results of a keyword search that returns results from the IBuySpy database:<ol><li>Complete the preceding steps for the Products by Category Search.</li><li>While holding down the ALT key, click the word "wallet" in the body of the letter.</li></ol></li><li><b class="bterm">Visual Results</b>. This query displays the following results in the <b class="bterm">Research</b> task pane:<p><img border="0" src="../img/rsimgWalkthrough3.gif" alt="The results of a keyword search (results found) query in the Research task pane"></p><p class="ac">Figure 3. The results of a keyword search (results found) query in the <b class="bterm">Research</b> task pane</p></li><li><b class="bterm">Query Request</b>. Here is the variable content from the query request sent to the IBuySpy.com Product Information research service. The query text consists of the word "Wallet."<pre><code>&lt;Context&gt;
    &lt;QueryText type='STRING' language='en-us' &gt;Wallet&lt;/QueryText&gt;
    ...
&lt;/Context&gt;
...
&lt;Keywords xmlns='urn:Microsoft.Search.Query.Office.Keywords' 
    revision='1'&gt;
    &lt;QueryText&gt;Wallet&lt;/QueryText&gt;
    &lt;Keyword&gt;
        &lt;Word&gt;Wallet&lt;/Word&gt;
    &lt;/Keyword&gt;
&lt;/Keywords&gt;
</code></pre></li><li><b class="bterm">Code</b>. The <b class="bterm"></b><code>Response_ProductKeywordSearch</code> method uses code similar to the <code>Response_ProductSummaryForCategory</code> method discussed in the preceding section to display similar product information, with a hyperlink for additional information and an actions menu.</li><li><b class="bterm">Query Response</b>. Here are the important portions of  the query response returned  by the IBuySpy.com Product Information research service. <pre><code>&lt;Range&gt;
    &lt;Results&gt;
        &lt;Content xmlns="urn:Microsoft.Search.Response.Content"&gt;
            &lt;P&gt;Your search returned the following results:&lt;/P&gt;
        &lt;/Content&gt;
        &lt;Content xmlns="urn:Microsoft.Search.Response.Content"&gt;
            &lt;Heading collapsible="true" collapsed="false"&gt;
                &lt;Text&gt;Counterfeit Creation Wallet&lt;/Text&gt;
                &lt;P&gt;Don't be caught ... your legal tender!&lt;/P&gt;
                &lt;P&gt;
                    &lt;Char bold="true"&gt;Product Price: &lt;/Char&gt;
                    &lt;Char&gt;$999.99&lt;/Char&gt;
                &lt;/P&gt;
                &lt;NewQuery query="DNTGCGHT"&gt;
                    &lt;Text&gt;Product Details ...&lt;/Text&gt;
                &lt;/NewQuery&gt;
                &lt;Actions&gt;
                    &lt;Insert&gt;
                        &lt;Text&gt;Insert Summary&lt;/Text&gt;
                    &lt;/Insert&gt;
                    &lt;Copy&gt;
                        &lt;Text&gt;Copy Summary&lt;/Text&gt;
                    &lt;/Copy&gt;
                    &lt;Data&gt;
                        Counterfeit Creation Wallet ... 
                        (Product Price: $999.99)
                    &lt;/Data&gt;
                &lt;/Actions&gt;
            &lt;/Heading&gt;
        &lt;/Content&gt;
        &lt;Content xmlns="urn:Microsoft.Search.Response.Content"&gt;
            &lt;P&gt;Your search returned 1 products.&lt;/P&gt;
        &lt;/Content&gt;
    &lt;/Results&gt;
&lt;/Range&gt;
</code></pre></li></ol></div><p><a href="#" class="DropDown" onclick="Outline2()" onkeypress="Outline2()"><img border="0" src="blueup.gif" alt="Show"><b class="bterm">Query</b> method: Product Details</a></p><div id="ExpCol" class="collapsed" border="0"><p>This section demonstrates a Product Details query and calls the <code>Response_ProductDetails</code> <b class="bterm"></b>private method in the IBuySpy sample.</p><ol><li><b class="bterm">Steps</b>. To view the results of a Product Details search:<ol><li>Complete the preceding steps for the keyword search (results found).</li><li>Click  the <b class="bterm">Product Details</b> hyperlink in the <b class="bterm">Research</b> task pane.</li></ol></li><li><b class="bterm">Visual Results</b>. This query displays the following results in the <b class="bterm">Research</b> task pane:<p><img border="0" src="../img/rsimgWalkthrough4.gif" alt="The results of a Product Details query in the Research task pane"></p><p class="ac">Figure 4. The results of a Product Details query in the <b class="bterm">Research</b> task pane</p></li><li><b class="bterm">Query Request</b>. Here is the variable content from the query request sent to the IBuySpy.com Product Information research service. The query text consists of the product ID, "DNTGCGHT," which is the value of the <b class="bterm">query</b> attribute of the <b class="bterm">NewQuery</b> element that we clicked.<pre><code>&lt;Context&gt;
    &lt;QueryText type='STRING' language='en-us' &gt;DNTGCGHT&lt;/QueryText&gt;
    ...
&lt;/Context&gt;
...
&lt;Keywords xmlns='urn:Microsoft.Search.Query.Office.Keywords' 
    revision='1'&gt;
    &lt;QueryText&gt;DNTGCGHT&lt;/QueryText&gt;
    &lt;Keyword&gt;
        &lt;Word&gt;DNTGCGHT&lt;/Word&gt;
    &lt;/Keyword&gt;
&lt;/Keywords&gt;</code></pre></li><li><b class="bterm">Code</b>. The <code>Response_ProductDetails</code> method displays extensive product information in the limited screen space of the task pane by making effective use of the elements of the <b class="bterm">Microsoft.Search.Response.Content</b> namespace, including:<ul><li>A product image.</li><li>Product details listed in table format by using the <b class="bterm">Tabular</b> element.</li><li>An actions menu that includes custom actions made possible by a smart tag.</li><li>A collapsed, hyperlinked list of Related Products.</li><li>Horizontal lines to divide sections of the results visually.</li><li>A <b class="bterm">NewQuery</b> element that invokes the Advanced Product Search form.</li></ul>The following code uses an <b class="bterm">XmlTextWriter</b> (not shown) to generate the table of Additional Product Details:<pre><code> 'Product Table of Details
.WriteStartElement("Tabular")
.WriteAttributeString("title", "Additional Product Details")
'Unit Cost
.WriteStartElement("Record")
.WriteElementString("Name", "Unit Cost")
.WriteElementString("Value", Format(productDetailsData("UnitCost"), _
    "Currency"))
.WriteEndElement() 'Record
'Units In Stock
.WriteStartElement("Record")
.WriteElementString("Name", "Units In Stock")
.WriteElementString("Value", productDetailsData("UnitsInStock"))
.WriteEndElement() 'Record
'Product Category
.WriteStartElement("Record")
.WriteElementString("Name", "Product Category")
'.WriteAttributeString("bold", "true")
.WriteElementString("Value", productDetailsData("CategoryName"))
.WriteStartElement("Actions")
.WriteStartElement("NewQuery")
.WriteAttributeString("query", productDetailsData("CategoryName"))
.WriteElementString("Text", "View Category Details")
.WriteEndElement() 'NewQuery
.WriteEndElement() 'Actions
.WriteEndElement() 'Record
'Model Number
.WriteStartElement("Record")
.WriteElementString("Name", "Model Number")
.WriteElementString("Value", productDetailsData("ModelNumber"))
.WriteEndElement() 'Record
.WriteEndElement() 'Tabular

</code></pre>The following code uses an <b class="bterm">XmlTextWriter</b> (not shown) to generate the menu of custom actions. Note the use of the <b class="bterm">WriteRaw</b> method of the <b class="bterm">XmlTextWriter</b> when concatenating a complex string of custom XML. <pre><code> Smart Tag
If applicationName = "Microsoft Word" Or applicationName = _
    "Microsoft Excel" Or applicationName = _
        "Microsoft Office Word" Then
    .WriteStartElement("Line")
    .WriteStartElement("Actions")
    .WriteStartElement("Custom")
    .WriteAttributeString("xmlns:pn", _
        "urn:schemas-microsoft-com.office11demos.ProductAnalysis")
    .WriteRaw("&lt;pn:ProductName ProductID='" &amp; _
        productDetailsData("ProductID") &amp; "' CategoryID='" &amp; _
            productDetailsData("CategoryID") &amp; "'&gt;" &amp; _
                productDetailsData("ModelNumber") &amp; _
                    "&lt;/pn:ProductName&gt;")
    .WriteEndElement()
    .WriteEndElement()
    .WriteEndElement()
End If 'End Smart Tag
</code></pre></li><li><b class="bterm">Query Response</b>. Here are the important portions of  the query response returned  by the IBuySpy.com Product Information research service.<pre><code>&lt;Range&gt;
    &lt;Results&gt;
        &lt;Content xmlns="urn:Microsoft.Search.Response.Content"&gt;
            &lt;P&gt;
                &lt;Char bold="true"&gt;Counterfeit Creation Wallet&lt;/Char&gt;
                &lt;Char light="true"&gt; (DNTGCGHT)&lt;/Char&gt;
            &lt;/P&gt;
            &lt;P&gt;Don't be caught ... your legal tender!&lt;/P&gt;
            &lt;HorizontalRule /&gt;
            &lt;Image source="http://servername/IBuySpyResearchPane/
                images/DNTGCGHT.gif" /&gt;
            &lt;HorizontalRule /&gt;
            &lt;Tabular title="Additional Product Details"&gt;
                &lt;Record&gt;
                    &lt;Name&gt;Unit Cost&lt;/Name&gt;
                    &lt;Value&gt;$999.99&lt;/Value&gt;
                &lt;/Record&gt;
                &lt;Record&gt;
                    &lt;Name&gt;Units In Stock&lt;/Name&gt;
                    &lt;Value&gt;10&lt;/Value&gt;
                &lt;/Record&gt;
                &lt;Record&gt;
                    &lt;Name&gt;Product Category&lt;/Name&gt;
                    &lt;Value&gt;Deception&lt;/Value&gt;
                    &lt;Actions&gt;
                        &lt;NewQuery query="Deception"&gt;
                            &lt;Text&gt;View Category Details&lt;/Text&gt;
                        &lt;/NewQuery&gt;
                    &lt;/Actions&gt;
                &lt;/Record&gt;
                &lt;Record&gt;
                    &lt;Name&gt;Model Number&lt;/Name&gt;
                    &lt;Value&gt;DNTGCGHT&lt;/Value&gt;
                &lt;/Record&gt;
            &lt;/Tabular&gt;
            &lt;Line&gt;
                &lt;Actions&gt;
                    &lt;Custom xmlns:pn="urn:schemas-microsoft-com.
                        office11demos.ProductAnalysis"&gt;
                        &lt;pn:ProductName ProductID="374" 
                            CategoryID="15"&gt;DNTGCGHT&lt;/pn:ProductName&gt;
                    &lt;/Custom&gt;
                &lt;/Actions&gt;
            &lt;/Line&gt;
            &lt;Heading collapsed="true"&gt;
                &lt;Text&gt;Related Products&lt;/Text&gt;
                &lt;NewQuery query="CITSME9"&gt;
                    &lt;Text&gt;CITSME9 - Cloaking Device&lt;/Text&gt;
                &lt;/NewQuery&gt;
                ...
                &lt;NewQuery query="THNKDKE1"&gt;
                        &lt;Text&gt;THNKDKE1 - Hologram Cufflinks&lt;/Text&gt;
                    &lt;/NewQuery&gt;
            &lt;/Heading&gt;
            &lt;HorizontalRule /&gt;
            &lt;NewQuery query="Advanced Product Search"&gt;
                &lt;Text&gt;Advanced product search ...&lt;/Text&gt;
            &lt;/NewQuery&gt;
        &lt;/Content&gt;
    &lt;/Results&gt;
&lt;/Range&gt;</code></pre></li></ol></div><p><a href="#" class="DropDown" onclick="Outline2()" onkeypress="Outline2()"><img border="0" src="blueup.gif" alt="Show"><b class="bterm">Query</b> method: Advanced Product Search form</a></p><div id="ExpCol" class="collapsed" border="0"><p>This section demonstrates the Advanced Product Search form and calls the <code>Response_AdvancedSearchForm</code> private method in the IBuySpy sample.</p><ol><li><b class="bterm">Steps</b>. To view the results of displaying the  Advanced Product Search form:<ol><li>Complete the preceding steps for the Product Details Search.</li><li>Click the <b class="bterm">Advanced product search</b> hyperlink displayed in the <b class="bterm">Research</b> task pane.</li></ol></li><li><b class="bterm">Visual Results</b>. This query displays the following results in the <b class="bterm">Research</b> task pane:<p><img border="0" src="../img/rsimgWalkthrough5.gif" alt="The results of displaying the Advanced Product Search form in the Research task pane"></p><p class="ac">Figure 5. The results of displaying the Advanced Product Search form in the <b class="bterm">Research</b> task pane</p></li><li><b class="bterm">Query Request</b>. Here is the variable content from the query request sent to the IBuySpy.com Product Information research service. The query text consists of the phrase, "Advanced Product Search," from the <b class="bterm">NewQuery</b> element that we clicked.<pre><code>&lt;Context&gt;
    &lt;QueryText type='STRING' language='en-us' &gt;
        Advanced Product Search
    &lt;/QueryText&gt;
    ...
&lt;/Context&gt;&lt;Range id='result'&gt;
...
&lt;Keywords xmlns='urn:Microsoft.Search.Query.Office.Keywords' 
    revision='1'&gt;
    &lt;QueryText&gt;Advanced Product Search&lt;/QueryText&gt;
    &lt;Keyword&gt;
        &lt;Word&gt;Advanced&lt;/Word&gt;
    &lt;/Keyword&gt;
    &lt;Keyword&gt;
        &lt;Word&gt;Product&lt;/Word&gt;
    &lt;/Keyword&gt;
    &lt;Keyword&gt;
        &lt;Word&gt;Search&lt;/Word&gt;
    &lt;/Keyword&gt;
&lt;/Keywords&gt;
</code></pre></li><li><b class="bterm">Code</b>. The <b class="bterm"></b><code>Response_AdvancedSearchForm</code> method demonstrates many elements of the <b class="bterm">Microsoft.Search.Response.Form</b> namespace, including:<ul><li>A group of radio buttons (<b class="bterm">RadioGroup</b> and <b class="bterm">Option</b> elements).</li><li><b class="bterm">Edit</b> elements for minimum and maximum price. (Since the same code also processes the advanced search, it contains some input validation and code to redisplay values that have already been entered.)</li><li>A <b class="bterm">Checkbox</b> element to limit the results to products that are currently in stock.</li>  <li>A <b class="bterm">Button</b> element to launch the search. The <b class="bterm">icon</b> attribute displays the built-in <b class="bterm">Go</b> icon, which consists of a green button image that contains an arrow.</li></ul> The following code uses an <b class="bterm">XmlTextWriter</b> (not shown) to generate the search form:<pre><code> 'Form Heading
.WriteStartElement("Form", "urn:Microsoft.Search.Response.Form")

'Radio Group of Categories
.WriteStartElement("RadioGroup")
.WriteAttributeString("id", "AdvancedSearchRadioGroup")
.WriteElementString("Text", "Select a Category for this search:")
'Add an "All Categories" to the list
.WriteStartElement("Option") 'Category Heading
.WriteAttributeString("id", "All")
.WriteAttributeString("selected", "true")
.WriteElementString("Text", "All Categories")
.WriteEndElement() 'Category Heading
categoryData = Utils.GetData_CategoryList()
While categoryData.Read
    .WriteStartElement("Option") 'Category Heading
    .WriteAttributeString("id", categoryData("CategoryName"))
    If categoryData("CategoryName") = category Then
        .WriteAttributeString("selected", "true")
    End If
    .WriteElementString("Text", categoryData("CategoryName"))
    .WriteEndElement() 'Category Heading
End While
.WriteEndElement() 'RadioGroup
If Not categoryData Is Nothing Then
    categoryData.Close()
End If

'Low Price Range Edit box
.WriteStartElement("Edit") 'Category Heading
.WriteAttributeString("id", "AdvancedSearchEditLow")
If lowPrice &lt;&gt; "" Then
    .WriteAttributeString("value", lowPrice)
End If
.WriteElementString("Text", "Product low price (Optional):")
.WriteEndElement()
If lowPrice &lt;&gt; "" And Not IsNumeric(lowPrice) Then
    .WriteElementString("Label", "Please provide a valid number for the Low Price.")
End If
'Low Price

'High Price Range Edit box
... 
'High Price

'In Stock check box
.WriteStartElement("Checkbox") 'Category Heading
.WriteAttributeString("id", "AdvancedSearchCheckbox")
If inStock = True Then
    .WriteAttributeString("selected", "true")
End If
.WriteElementString("Text", "Only show items in stock")
.WriteEndElement() 'Checkbox

'Search Button
.WriteStartElement("Button") 'Category Heading
.WriteAttributeString("id", "AdvancedSearchButton")
.WriteAttributeString("icon", "go")
.WriteAttributeString("action", "requery")
.WriteEndElement() 'Low Price

.WriteEndElement() 'Form
</code></pre></li><li><b class="bterm">Query Response</b>. Here are the important portions of  the query response returned  by the IBuySpy.com Product Information research service.<pre><code>&lt;Range&gt;
    &lt;Results&gt;
        &lt;Form xmlns="urn:Microsoft.Search.Response.Form"&gt;
            &lt;RadioGroup id="AdvancedSearchRadioGroup"&gt;
                &lt;Text&gt;Select a Category for this search:&lt;/Text&gt;
                &lt;Option id="All" selected="true"&gt;
                    &lt;Text&gt;All Categories&lt;/Text&gt;
                &lt;/Option&gt;
                &lt;Option id="Communications"&gt;
                    &lt;Text&gt;Communications&lt;/Text&gt;
                &lt;/Option&gt;
                ...
                &lt;Option id="Travel"&gt;
                    &lt;Text&gt;Travel&lt;/Text&gt;
                &lt;/Option&gt;
            &lt;/RadioGroup&gt;
            &lt;Edit id="AdvancedSearchEditLow"&gt;
                &lt;Text&gt;Product low price (Optional):&lt;/Text&gt;
            &lt;/Edit&gt;
            &lt;Edit id="AdvancedSearchEditHigh"&gt;
                &lt;Text&gt;Product high price (Optional):&lt;/Text&gt;
            &lt;/Edit&gt;
            &lt;Checkbox id="AdvancedSearchCheckbox"&gt;
                &lt;Text&gt;Only show items in stock&lt;/Text&gt;
            &lt;/Checkbox&gt;
            &lt;Button id="AdvancedSearchButton" 
                icon="go" action="requery" /&gt;
        &lt;/Form&gt;
        &lt;Content xmlns="urn:Microsoft.Search.Response.Content" /&gt;
    &lt;/Results&gt;
&lt;/Range&gt;</code></pre></li></ol></div><p><a href="#" class="DropDown" onclick="Outline2()" onkeypress="Outline2()"><img border="0" src="blueup.gif" alt="Show"><b class="bterm">Query</b> method: Advanced Product Search results</a></p><div id="ExpCol" class="collapsed" border="0"><p>This section demonstrates the results from an Advanced Product Search query and also calls the <code>Response_AdvancedSearchForm</code> private method in the IBuySpy sample.</p><ol><li><b class="bterm">Steps</b>. To view the results of an  Advanced Product Search:<ol><li>Complete the preceding steps for displaying the Advanced Product Search form.</li><li>In the form, fill in values for low and high price, select the <b class="bterm">In stock</b> check box, and click <b class="bterm">Go</b>.</li></ol></li><li><b class="bterm">Visual Results</b>. This query displays the following results in the <b class="bterm">Research</b> task pane:<p><img border="0" src="../img/rsimgWalkthrough6.gif" alt="The results of an Advanced Product Search query in the Research task pane"></p><p class="ac">Figure 6. The results of an Advanced Product Search query in the <b class="bterm">Research</b> task pane</p></li><li><b class="bterm">Query Request</b>. Here is the complete text of the query request sent to the IBuySpy.com Product Information research service. The query text again consists of the phrase, "Advanced Product Search," because of the "requery" value of the <b class="bterm">action</b> attribute of the <b class="bterm">Button</b> element that we clicked.<pre><code>&lt;QueryPacket xmlns='urn:Microsoft.Search.Query' 
    revision='1' build='(11.0.5606)' &gt;
    &lt;Query domain='{1698075D-E2F5-4254-87B2-7FC9E9AB0780}'&gt;
        &lt;QueryId&gt;{1529838F-8A6F-4949-92A5-39DD419D535E}&lt;/QueryId&gt;
        &lt;OriginatorId&gt;
            {F6FF7BE0-F39C-4ddc-A7D0-09A4C6C647A5}
        &lt;/OriginatorId&gt;
        &lt;SupportedFormats&gt;
            &lt;Format revision='1'&gt;
                urn:Microsoft.Search.Response.Document:Document
            &lt;/Format&gt;
            &lt;Format revision='1'&gt;
                urn:Microsoft.Search.Response.Content:Content
            &lt;/Format&gt;
            &lt;Format revision='1'&gt;
                urn:Microsoft.Search.Response.Form:Form
            &lt;/Format&gt;
        &lt;/SupportedFormats&gt;
        &lt;Context&gt;
            &lt;QueryText type='STRING' language='en-us' &gt;
                Advanced Product Search
            &lt;/QueryText&gt;
            &lt;LanguagePreference&gt;en-us&lt;/LanguagePreference&gt;
            &lt;Requery&gt;
                &lt;ServiceParameters 
                    xmlns=
                    'urn:Microsoft.Search.Office.ServiceParameters'&gt;
                    &lt;Action&gt;AdvancedSearchButton&lt;/Action&gt;
                    &lt;Parameters&gt;
                        &lt;AdvancedSearchRadioGroup&gt;
                            All
                        &lt;/AdvancedSearchRadioGroup&gt;
                        &lt;AdvancedSearchEditLow&gt;
                            500
                        &lt;/AdvancedSearchEditLow&gt;
                        &lt;AdvancedSearchEditHigh&gt;
                            1500
                        &lt;/AdvancedSearchEditHigh&gt;
                        &lt;AdvancedSearchCheckbox/&gt;
                    &lt;/Parameters&gt;
                &lt;/ServiceParameters&gt;
            &lt;/Requery&gt;
        &lt;/Context&gt;
        &lt;Range id='result'&gt;&lt;/Range&gt;
        &lt;OfficeContext 
            xmlns='urn:Microsoft.Search.Query.Office.Context' 
            revision='1'&gt;
            &lt;UserPreferences&gt;
                &lt;ParentalControl&gt;false&lt;/ParentalControl&gt;
            &lt;/UserPreferences&gt;
            &lt;ServiceData&gt;&lt;/ServiceData&gt;
            &lt;ApplicationContext&gt;
                &lt;Name&gt;Microsoft Office Word&lt;/Name&gt;
                &lt;Version&gt;(11.0.5606)&lt;/Version&gt;
                &lt;SystemInformation&gt;
                    &lt;SkuLanguage&gt;en-us&lt;/SkuLanguage&gt;
                    &lt;LanguagePack&gt;en-us&lt;/LanguagePack&gt;
                    &lt;InterfaceLanguage&gt;en-us&lt;/InterfaceLanguage&gt;
                    &lt;Location&gt;US&lt;/Location&gt;
                &lt;/SystemInformation&gt;
            &lt;/ApplicationContext&gt;
            &lt;QueryLanguage&gt;en-us&lt;/QueryLanguage&gt;
            &lt;KeyboardLanguage&gt;en-us&lt;/KeyboardLanguage&gt;
        &lt;/OfficeContext&gt;
        &lt;Keywords 
            xmlns='urn:Microsoft.Search.Query.Office.Keywords' 
            revision='1'&gt;
            &lt;QueryText&gt;Advanced Product Search&lt;/QueryText&gt;
            &lt;Keyword&gt;
                &lt;Word&gt;Advanced&lt;/Word&gt;
            &lt;/Keyword&gt;
            &lt;Keyword&gt;
                &lt;Word&gt;Product&lt;/Word&gt;
            &lt;/Keyword&gt;
            &lt;Keyword&gt;
                &lt;Word&gt;Search&lt;/Word&gt;
            &lt;/Keyword&gt;
        &lt;/Keywords&gt;
    &lt;/Query&gt;
&lt;/QueryPacket&gt;</code></pre></li><li><b class="bterm">Code</b>. The code in the <b class="bterm"></b><code>Response_AdvancedSearchForm</code> method now regenerates the form, with the user's input displayed in the form elements, followed by a list of matching products. The following code uses an <b class="bterm">XmlTextWriter</b> (not shown) to produce the list of records that match the search criteria:<pre><code>Dim countRecords As Integer = 0 'Track number of returned records
    If category &lt;&gt; "" Then
    productsData = Utils.GetData_DataProductsAdvancedSearch( _
        category, lowPrice, highPrice, inStock)
    .WriteElementString("HorizontalRule", "")
    'Each product is now listed
    While productsData.Read
        countRecords += 1
        If countRecords = 1 Then
            .WriteElementString("P", _
                "Your search returned the following results:")
        End If
        'Product Heading
        .WriteStartElement("P")
        .WriteStartElement("Char")
        .WriteAttributeString("bold", "true")
        .WriteString(productsData("ModelName") &amp; ":")
        .WriteEndElement()
        'Product Details
        .WriteString(" " &amp; Left(productsData("Description"), 80) &amp; _
            "....")
        .WriteEndElement() 'Product Heading
        'New Query to get more product details
        .WriteStartElement("NewQuery")
        .WriteAttributeString("query", productsData("ModelNumber"))
        .WriteElementString("Text", "Product Details ...")
        .WriteEndElement()
        '.WriteElementString("P", "")
    End While
    If countRecords = 0 Then
        'No records, throw general exception 
        'will return a no result error
        Dim eTemp As Exception
        Throw eTemp
    Else
        .WriteElementString("P", "Your search returned " &amp; _
            countRecords &amp; " products.")
    End If
End If
</code></pre></li><li><b class="bterm">Query Response</b>. Here are the important portions of  the query response returned  by the IBuySpy.com Product Information research service.<pre><code>&lt;Range&gt;
    &lt;Results&gt;
        &lt;Form xmlns="urn:Microsoft.Search.Response.Form"&gt;
            &lt;RadioGroup id="AdvancedSearchRadioGroup"&gt;
                &lt;Text&gt;Select a Category for this search:&lt;/Text&gt;
                &lt;Option id="All" selected="true"&gt;
                    &lt;Text&gt;All Categories&lt;/Text&gt;
                &lt;/Option&gt;
                &lt;Option id="Communications"&gt;
                    &lt;Text&gt;Communications&lt;/Text&gt;
                &lt;/Option&gt;
                ...
                &lt;Option id="Travel"&gt;
                    &lt;Text&gt;Travel&lt;/Text&gt;
                &lt;/Option&gt;
            &lt;/RadioGroup&gt;
            &lt;Edit id="AdvancedSearchEditLow" value="500"&gt;
                &lt;Text&gt;Product low price (Optional):&lt;/Text&gt;
            &lt;/Edit&gt;
            &lt;Edit id="AdvancedSearchEditHigh" value="1500"&gt;
                &lt;Text&gt;Product high price (Optional):&lt;/Text&gt;
            &lt;/Edit&gt;
            &lt;Checkbox id="AdvancedSearchCheckbox" selected="true"&gt;
                &lt;Text&gt;Only show items in stock&lt;/Text&gt;
            &lt;/Checkbox&gt;
            &lt;Button id="AdvancedSearchButton" icon="go" 
                action="requery" /&gt;
        &lt;/Form&gt;
        &lt;Content xmlns="urn:Microsoft.Search.Response.Content"&gt;
            &lt;HorizontalRule /&gt;
            &lt;P&gt;Your search returned the following results:&lt;/P&gt;
            &lt;P&gt;
                &lt;Char bold="true"&gt;
                    Counterfeit Creation Wallet:
                &lt;/Char&gt; ...
            &lt;/P&gt;
                &lt;NewQuery query="PT109"&gt;
                    &lt;Text&gt;Product Details ...&lt;/Text&gt;
                &lt;/NewQuery&gt;
                ...
                &lt;P&gt;
                    &lt;Char bold="true"&gt;Rain Racer 2000:
                &lt;/Char&gt; ...
             &lt;/P&gt;
            &lt;NewQuery query="RU007"&gt;
                &lt;Text&gt;Product Details ...&lt;/Text&gt;
            &lt;/NewQuery&gt;
            &lt;P&gt;Your search returned 4 products.&lt;/P&gt;
        &lt;/Content&gt;
    &lt;/Results&gt;
&lt;/Range&gt;</code></pre></li></ol></div><center><a href="XMLSchemaCopyright_HV01147162.htm">&copy;2003-2004 Microsoft Corporation. All rights reserved.</a>  

Permission to copy, display and distribute this document is available at: <a 

href="http://r.office.microsoft.com/r/rlidAWSContentRedir?AssetID=XT010988631033&amp;CTT=11&amp;Origin=HV011232471033" 

target="_new">http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp</a></center></body></html>