Introduction |
|
1 | (8) |
|
What Does This Book Cover? |
|
|
1 | (3) |
|
What You Need to Use This Book |
|
|
4 | (1) |
|
|
5 | (1) |
|
|
5 | (1) |
|
|
5 | (4) |
|
|
6 | (1) |
|
|
6 | (3) |
Chapter 1: SQL Server, XML, and the DBA |
|
9 | (22) |
|
|
10 | (3) |
|
The Success of Relational Databases |
|
|
10 | (1) |
|
|
11 | (1) |
|
|
12 | (5) |
|
System Interoperability and Data Interchange in an n-tier Environment |
|
|
13 | (1) |
|
|
13 | (1) |
|
What Aspects of XML are Relevant to Databases? |
|
|
13 | (4) |
|
XML and Relational Structures |
|
|
17 | (1) |
|
|
17 | (1) |
|
|
17 | (2) |
|
Storing XML in Relational Structures |
|
|
18 | (1) |
|
Storing Relational Data Using XML |
|
|
18 | (1) |
|
Mapping XML and Relational Data |
|
|
18 | (1) |
|
The Main Uses of XML Structures |
|
|
19 | (1) |
|
XML for Messaging - The Other Application Wants XML |
|
|
19 | (1) |
|
XML as Document - Markup Based Document Objects |
|
|
20 | (1) |
|
XML for Presentation - The Browser Wants Markup |
|
|
20 | (1) |
|
|
20 | (8) |
|
Different Approaches to the Problem |
|
|
21 | (6) |
|
|
21 | (2) |
|
Relational End-to (near the)-end |
|
|
23 | (1) |
|
|
24 | (1) |
|
|
25 | (2) |
|
|
27 | (1) |
|
|
28 | (3) |
Chapter 2: Architecture and Setup |
|
31 | (28) |
|
|
31 | (11) |
|
Architecture of SQL Server 2000 XML |
|
|
32 | (2) |
|
|
32 | (1) |
|
|
33 | (1) |
|
|
34 | (7) |
|
|
34 | (1) |
|
|
35 | (1) |
|
|
36 | (1) |
|
|
37 | (1) |
|
|
38 | (1) |
|
|
38 | (1) |
|
|
39 | (1) |
|
|
40 | (1) |
|
|
40 | (1) |
|
|
41 | (1) |
|
|
41 | (1) |
|
Where SQLXML Fits With NET/DNA |
|
|
42 | (1) |
|
|
42 | (2) |
|
|
42 | (1) |
|
|
43 | (1) |
|
Creating SQLXML Virtual Directories |
|
|
44 | (12) |
|
|
45 | (1) |
|
|
46 | (1) |
|
|
47 | (1) |
|
|
48 | (2) |
|
|
50 | (1) |
|
|
51 | (1) |
|
|
52 | (1) |
|
|
52 | (1) |
|
|
53 | (1) |
|
|
53 | (1) |
|
|
54 | (1) |
|
|
54 | (1) |
|
|
54 | (1) |
|
|
54 | (2) |
|
|
56 | (1) |
|
|
56 | (1) |
|
|
56 | (1) |
|
|
56 | (1) |
|
|
57 | (2) |
Chapter 3: Mapping SQL Server to XML |
|
59 | (32) |
|
Considerations When Mapping Data |
|
|
59 | (5) |
|
|
59 | (2) |
|
|
61 | (1) |
|
|
62 | (1) |
|
|
63 | (1) |
|
XML Schemas vs. XML-Data Reduced Schemas |
|
|
64 | (1) |
|
|
65 | (9) |
|
|
74 | (7) |
|
Identification of Relevant Information |
|
|
74 | (1) |
|
Design of XML Document Overall Structure |
|
|
75 | (3) |
|
Sequence, Choice, or All? |
|
|
75 | (1) |
|
Understanding Foreign Key Relationships |
|
|
76 | (1) |
|
Proper Usage of ID-IDREF Relationships |
|
|
77 | (1) |
|
Handling "Dangling" Elements |
|
|
78 | (1) |
|
|
78 | (3) |
|
|
79 | (1) |
|
|
79 | (1) |
|
Include or Exclude Identifiers |
|
|
80 | (1) |
|
|
81 | (1) |
|
|
81 | (1) |
|
Using an XML View to Create the XML Document |
|
|
82 | (1) |
|
Using FOR XML EXPLICIT to Create the XML Document |
|
|
82 | (1) |
|
|
82 | (7) |
|
|
82 | (1) |
|
Identifying the Relevant Information |
|
|
83 | (1) |
|
Designing the Document Structure |
|
|
83 | (2) |
|
Mapping the Column Values |
|
|
85 | (1) |
|
A FOR XML EXPLICIT Query Mapping the Data to XML |
|
|
86 | (3) |
|
|
89 | (2) |
Chapter 4: FOR XML |
|
91 | (30) |
|
Comparison of Server-Side and Client-Side XML Processing |
|
|
92 | (1) |
|
|
93 | (1) |
|
Server-Side XML Processing |
|
|
94 | (23) |
|
|
95 | (1) |
|
|
95 | (1) |
|
|
96 | (1) |
|
|
96 | (3) |
|
|
98 | (1) |
|
|
98 | (1) |
|
|
99 | (5) |
|
|
103 | (1) |
|
|
104 | (13) |
|
|
110 | (7) |
|
Client-Side XML Processing |
|
|
117 | (2) |
|
|
118 | (1) |
|
|
118 | (1) |
|
|
119 | (1) |
|
Ways of Using Client-Side FOR XML |
|
|
119 | (1) |
|
|
119 | (2) |
Chapter 5: URL Queries and Template Queries |
|
121 | (24) |
|
|
121 | (11) |
|
|
122 | (1) |
|
Setting up the Environment |
|
|
123 | (1) |
|
|
123 | (9) |
|
|
125 | (1) |
|
Executing Stored Procedures |
|
|
125 | (2) |
|
|
127 | (3) |
|
|
130 | (2) |
|
|
132 | (11) |
|
|
132 | (1) |
|
|
133 | (1) |
|
Setting up the Environment |
|
|
133 | (2) |
|
Template and XSL Stylesheet Caching |
|
|
134 | (1) |
|
|
135 | (12) |
|
|
136 | (1) |
|
|
136 | (2) |
|
|
138 | (2) |
|
|
140 | (1) |
|
|
140 | (1) |
|
|
141 | (1) |
|
|
141 | (1) |
|
|
142 | (1) |
|
|
143 | (2) |
Chapter 6: Annotating XML Schemas |
|
145 | (28) |
|
Why Annotate XML Schemas? |
|
|
145 | (1) |
|
XML Schemas vs. XDR Schemas |
|
|
146 | (1) |
|
The XML Schema Annotation Namespace |
|
|
146 | (1) |
|
|
147 | (21) |
|
Mapping Complex Elements to SQL Server Tables |
|
|
147 | (1) |
|
Mapping Attributes to SQL Server Columns |
|
|
148 | (1) |
|
Mapping Text-only Elements to SQL Server Columns |
|
|
149 | (1) |
|
Defining Unmapped XML Elements |
|
|
150 | (1) |
|
Excluding XML Elements From the Mapping |
|
|
151 | (1) |
|
Specifying Relationships Between Two SQL Tables |
|
|
152 | (3) |
|
Filtering the Data in an XML Document |
|
|
155 | (2) |
|
Specifying Unique Keys in an XML Document |
|
|
157 | (2) |
|
Creating ID-IDREF Relationships in XML Schemas |
|
|
159 | (2) |
|
Escaping Invalid XML Characters in XML Schemas |
|
|
161 | (1) |
|
Mapping Binary Large Objects (BLOBS) |
|
|
162 | (3) |
|
Specifying Identity Columns in an XML Schema |
|
|
165 | (1) |
|
Specifying a GUID in an XML Schema |
|
|
166 | (1) |
|
Limiting Recursion Depths in XML Schemas |
|
|
167 | (1) |
|
|
168 | (5) |
Chapter 7: XML Views |
|
173 | (14) |
|
The What and Why of XML Views |
|
|
173 | (1) |
|
|
174 | (6) |
|
Annotating an Existing XDR or XML Schema |
|
|
175 | (1) |
|
Modeling Tables and Columns in XML Views |
|
|
175 | (2) |
|
Modeling Joins in XML Views |
|
|
177 | (3) |
|
Accessing Data Through an XML View |
|
|
180 | (1) |
|
Accessing Data Using URLs |
|
|
180 | (1) |
|
Accessing Data Using Templates |
|
|
180 | (1) |
|
|
181 | (4) |
|
|
181 | (2) |
|
Layering an XML View Over a SQL Server View |
|
|
183 | (2) |
|
|
185 | (2) |
Chapter 8: XPath Queries |
|
187 | (26) |
|
|
187 | (1) |
|
|
188 | (2) |
|
|
188 | (1) |
|
|
189 | (1) |
|
|
190 | (9) |
|
|
190 | (1) |
|
|
190 | (3) |
|
|
191 | (2) |
|
|
193 | (6) |
|
|
195 | (3) |
|
|
198 | (1) |
|
|
198 | (1) |
|
|
199 | (3) |
|
|
199 | (1) |
|
XPath Queries in Templates |
|
|
199 | (3) |
|
|
201 | (1) |
|
|
202 | (1) |
|
XPath Queries in the Managed Classes |
|
|
202 | (1) |
|
Performance Considerations |
|
|
202 | (5) |
|
Tuning XPath Using SQL Profiler |
|
|
202 | (1) |
|
|
203 | (4) |
|
|
207 | (1) |
|
Who Has Access to the Data? |
|
|
207 | (1) |
|
|
207 | (1) |
|
|
208 | (1) |
|
|
208 | (2) |
|
|
210 | (3) |
Chapter 9: Mapping XML to SQL Server |
|
213 | (34) |
|
|
213 | (6) |
|
|
213 | (2) |
|
Loading Temporary Data for Manipulation |
|
|
215 | (2) |
|
|
217 | (2) |
|
Equivalent SQL Data Types |
|
|
219 | (5) |
|
Types to Avoid in XML Data Destined for SQL Server |
|
|
223 | (1) |
|
|
224 | (15) |
|
|
224 | (1) |
|
Identification of Relevant Information |
|
|
225 | (1) |
|
Design of the Overall Relational Structure |
|
|
226 | (9) |
|
|
226 | (5) |
|
Handling ID-IDREF Relationships |
|
|
231 | (2) |
|
Handling ID-IDREFS Relationships |
|
|
233 | (2) |
|
|
235 | (4) |
|
|
237 | (1) |
|
Creating Constraints Based on XML Schema Constraints |
|
|
237 | (1) |
|
Modeling Enumeration Constraints |
|
|
238 | (1) |
|
Creating Record Identifiers |
|
|
239 | (1) |
|
|
239 | (5) |
|
|
241 | (1) |
|
Identifying the Relevant Information |
|
|
241 | (1) |
|
|
241 | (1) |
|
Mapping the Column Values |
|
|
242 | (2) |
|
|
244 | (3) |
Chapter 10: OPENXML |
|
247 | (44) |
|
|
247 | (1) |
|
Parsing an XML document with OPENXML |
|
|
248 | (5) |
|
|
250 | (2) |
|
|
252 | (1) |
|
|
253 | (14) |
|
|
253 | (2) |
|
|
255 | (3) |
|
|
256 | (2) |
|
|
258 | (4) |
|
|
258 | (2) |
|
Set Operations in the rowpattern |
|
|
260 | (2) |
|
|
262 | (3) |
|
|
264 | (1) |
|
|
265 | (14) |
|
Specifying metaproperties |
|
|
266 | (1) |
|
Combining with Other Tables |
|
|
267 | (4) |
|
Using XML Data to Modify Tables |
|
|
271 | (8) |
|
|
279 | (4) |
|
|
280 | (2) |
|
Edge Table with DTD or Inline Schema |
|
|
282 | (1) |
|
|
283 | (3) |
|
|
283 | (1) |
|
|
284 | (1) |
|
|
285 | (1) |
|
|
286 | (1) |
|
|
286 | (1) |
|
|
286 | (1) |
|
Whitespace and Escaped Characters |
|
|
286 | (1) |
|
|
287 | (1) |
|
|
287 | (4) |
Chapter 11: Updategrams |
|
291 | (36) |
|
|
292 | (3) |
|
Driving Updategrams with an Annotated Schema |
|
|
295 | (2) |
|
Default Mapping in Updategrams |
|
|
297 | (1) |
|
Inserting Data with an Updategram |
|
|
298 | (4) |
|
|
301 | (1) |
|
Deleting Data with an Updategram |
|
|
302 | (2) |
|
|
303 | (1) |
|
Updating Data with an Updategram |
|
|
304 | (3) |
|
Explicitly Relating Records |
|
|
306 | (1) |
|
Explicitly Relating Before and After |
|
|
307 | (1) |
|
Multiple Actions Within One Updategram |
|
|
307 | (4) |
|
Capturing Identity Values for Inserted Records |
|
|
311 | (4) |
|
Inverse Relationships in an Updategram |
|
|
315 | (2) |
|
Creating GUIDs as Part of an Updategram |
|
|
317 | (1) |
|
Generating Updategrams "on-the-fly" |
|
|
318 | (1) |
|
Applying Updategrams to a Database |
|
|
319 | (5) |
|
Applying an Updategram Using HTTP |
|
|
319 | (1) |
|
Applying an Updategram from a URL |
|
|
320 | (1) |
|
Applying Updategrams from Templates |
|
|
320 | (2) |
|
Applying an Updategram Directly Using HTTP Post |
|
|
322 | (1) |
|
Applying an Updategram Using ADO |
|
|
323 | (1) |
|
|
324 | (3) |
Chapter 12: SQLXML Bulk Load |
|
327 | (36) |
|
|
328 | (2) |
|
|
330 | (5) |
|
|
335 | (1) |
|
Properties of the SQLXMLBulkLoad Object |
|
|
336 | (8) |
|
Providing Connection information |
|
|
336 | (2) |
|
Table Creation and Deletion |
|
|
338 | (1) |
|
|
339 | (1) |
|
|
340 | (1) |
|
|
341 | (1) |
|
Control over Data Loading |
|
|
342 | (2) |
|
|
342 | (1) |
|
|
343 | (1) |
|
|
343 | (1) |
|
|
343 | (1) |
|
|
344 | (1) |
|
Completing the Script and Running it in DTS |
|
|
344 | (12) |
|
|
348 | (6) |
|
Loading From a Stream Instead of a File |
|
|
354 | (2) |
|
Differences from Other Bulk Load Interfaces |
|
|
356 | (3) |
|
Comparison to Updategrams |
|
|
358 | (1) |
|
|
358 | (1) |
|
|
359 | (4) |
Chapter 13: Programmatic Access with SQLXML |
|
363 | (52) |
|
|
365 | (24) |
|
Extended Properties of the ADO Command Object |
|
|
368 | (7) |
|
|
369 | (1) |
|
|
369 | (1) |
|
|
370 | (1) |
|
|
370 | (1) |
|
|
371 | (1) |
|
|
371 | (3) |
|
|
374 | (1) |
|
|
375 | (1) |
|
|
375 | (2) |
|
Querying Using XPath and a Mapping Schema |
|
|
377 | (4) |
|
SQLXMLOLEDB Provider and Client-Side Processing |
|
|
381 | (7) |
|
|
383 | (1) |
|
Coding for Client-Side XML |
|
|
383 | (1) |
|
Querying Stored Procedures to Get XML |
|
|
384 | (1) |
|
Letting ADO Create the XML |
|
|
385 | (3) |
|
Using ADO and a Stored Procedure with OPENXML |
|
|
388 | (1) |
|
Programming XML with ADO.NET |
|
|
389 | (4) |
|
Executing a FOR XML Query With SqlCommand |
|
|
390 | (2) |
|
Saving ADO.NET Datasets as XML |
|
|
392 | (1) |
|
|
393 | (11) |
|
|
394 | (7) |
|
Properties of SqlXmlCommand |
|
|
395 | (5) |
|
|
400 | (1) |
|
|
401 | (1) |
|
|
402 | (2) |
|
|
404 | (8) |
|
|
412 | (3) |
Chapter 14: Web Services in SQL Server 2000 |
|
415 | (18) |
|
|
415 | (1) |
|
Setting up a SQL Server 2000 Web Service With SQLXML 3.0 |
|
|
416 | (8) |
|
|
416 | (2) |
|
Creating the SOAP Virtual Name |
|
|
418 | (1) |
|
Exposing Stored Procedure Functionality as a Web Service |
|
|
419 | (1) |
|
|
420 | (3) |
|
|
421 | (1) |
|
|
422 | (1) |
|
|
423 | (1) |
|
Stored Procedure Return Codes |
|
|
423 | (1) |
|
|
423 | (1) |
|
Exposing UDF Functionality as a Web Service |
|
|
423 | (1) |
|
Consuming Services Through Visual Studio.NET |
|
|
424 | (2) |
|
Further SQL Server 2000 Web Service Topics |
|
|
426 | (4) |
|
|
426 | (1) |
|
Web Service Security/Authentication |
|
|
427 | (1) |
|
Shortcomings of SQL Server Web Services |
|
|
427 | (1) |
|
|
427 | (1) |
|
No Control Over Return Values |
|
|
428 | (1) |
|
Wrapping Services with .NET Services |
|
|
428 | (2) |
|
|
430 | (3) |
Chapter 15: Case Study: Detecting Web Site Clients |
|
433 | (24) |
|
Benefits and Drawbacks of the Methods |
|
|
434 | (1) |
|
|
434 | (1) |
|
Client Detection Using SQLXML |
|
|
435 | (9) |
|
|
435 | (1) |
|
|
435 | (1) |
|
The Solution to SQLXML Client Detection |
|
|
435 | (8) |
|
The SQLXML Virtual Directory |
|
|
436 | (1) |
|
Creating the XML Templates |
|
|
436 | (3) |
|
Creating Client Detection Code |
|
|
439 | (4) |
|
Drawbacks to Client Detection in SQLXML |
|
|
443 | (1) |
|
Client Detection Using the SQLXML Managed Classes |
|
|
444 | (7) |
|
Visual Studio.NET and the NET Framework |
|
|
444 | (1) |
|
|
444 | (1) |
|
ASP.NET Browser Detection |
|
|
445 | (1) |
|
|
446 | (1) |
|
Plugging in our SQLXML Templates |
|
|
447 | (3) |
|
Advantages to Using ASP.NET Client Detection |
|
|
450 | (1) |
|
Client Detection Using SQLXML and ADO |
|
|
451 | (3) |
|
|
451 | (2) |
|
|
453 | (1) |
|
Advantages to Using ASP Client Detection |
|
|
454 | (1) |
|
|
454 | (3) |
Chapter 16: Case Study: BizTalk Integration |
|
457 | (38) |
|
|
458 | (1) |
|
HR and Departmental Databases |
|
|
459 | (3) |
|
|
459 | (2) |
|
|
461 | (1) |
|
|
461 | (1) |
|
|
462 | (2) |
|
|
463 | (1) |
|
|
463 | (1) |
|
|
464 | (1) |
|
|
464 | (1) |
|
|
465 | (1) |
|
|
465 | (8) |
|
|
465 | (4) |
|
|
469 | (4) |
|
HR Orchestration Schedule |
|
|
473 | (12) |
|
|
474 | (1) |
|
|
474 | (2) |
|
HR Messaging Implementations |
|
|
476 | (4) |
|
|
480 | (1) |
|
BizTalk Messaging Configuration |
|
|
481 | (4) |
|
Department Phone List Schedule |
|
|
485 | (4) |
|
Department Business Process |
|
|
485 | (1) |
|
Department Messaging Implementations |
|
|
486 | (1) |
|
|
487 | (1) |
|
BizTalk Messaging Configuration |
|
|
488 | (1) |
|
|
489 | (1) |
|
|
490 | (2) |
|
|
490 | (1) |
|
|
491 | (1) |
|
|
492 | (3) |
Chapter 17: The Future - Emergent Technologies |
|
495 | (18) |
|
ISO SQL/XML Working Draft (or SQLX) |
|
|
496 | (1) |
|
Oracle 9i Release 2 (9.0.2) |
|
|
496 | (4) |
|
|
497 | (3) |
|
What's so Good About the Native xmltype? |
|
|
497 | (1) |
|
And What's So Good About the Integrated Support for XML Schema? |
|
|
498 | (1) |
|
What About These Integrated Functions? |
|
|
499 | (1) |
|
|
500 | (1) |
|
|
500 | (1) |
|
|
500 | (9) |
|
|
500 | (1) |
|
XQuery and XPath 2.0, XSLT and XPath 1.0 and 2.0 |
|
|
501 | (1) |
|
|
501 | (13) |
|
|
502 | (1) |
|
FLoWeR - or FOR LET WHERE RETURN |
|
|
503 | (2) |
|
|
505 | (2) |
|
|
507 | (1) |
|
|
507 | (1) |
|
Data Types and Validation |
|
|
508 | (1) |
|
XQuery Future - In the Pipeline |
|
|
508 | (1) |
|
|
508 | (1) |
|
Microsoft Next Steps - Yukon |
|
|
509 | (1) |
|
So What Does all This Mean? |
|
|
510 | (3) |
Appendix A: XPath Reference |
|
513 | (46) |
|
|
514 | (7) |
|
|
516 | (1) |
|
|
516 | (2) |
|
|
518 | (3) |
|
|
521 | (8) |
|
Absolute and Relative Location Paths |
|
|
521 | (1) |
|
|
522 | (1) |
|
|
522 | (3) |
|
|
525 | (2) |
|
|
527 | (1) |
|
|
527 | (2) |
|
|
529 | (1) |
|
|
530 | (4) |
|
|
530 | (1) |
|
|
531 | (2) |
|
|
533 | (1) |
|
|
533 | (1) |
|
|
534 | (18) |
|
|
552 | (7) |
|
|
552 | (3) |
|
|
555 | (4) |
Appendix B: XML Schema Reference |
|
559 | (42) |
|
Namespaces for XML Schema |
|
|
559 | (1) |
|
|
560 | (10) |
|
|
560 | (10) |
|
|
|
|
|
|
|
|
|
|
|
Defining and Constraining Types |
|
|
570 | (15) |
|
|
|
|
|
|
575 | (7) |
|
Complex Type Restrictions |
|
|
582 | (3) |
|
Relationships and Null Fields |
|
|
585 | (6) |
|
|
|
|
|
|
|
|
591 | (2) |
|
|
591 | (2) |
|
|
593 | (1) |
|
|
|
|
|
|
|
|
594 | (1) |
|
|
|
|
|
|
595 | (2) |
|
|
|
|
|
The XML Schema Instance Namespace |
|
|
597 | (2) |
|
|
599 | (2) |
Appendix C: A Tool for XML Queries |
|
601 | (8) |
|
Why is a Query Tool Useful? |
|
|
601 | (2) |
|
|
603 | (6) |
Index |
|
609 | |