- Page 2 and 3:
Applied XML Programming for Microso
- Page 4 and 5:
services. Rainer Heller of Siemens
- Page 6 and 7:
IntroductionIt was about five years
- Page 8 and 9:
What Do I Need to Use This Book?Mos
- Page 10 and 11:
Part I: XML Core Classes in the .NE
- Page 12 and 13:
Related XML StandardsTable 1-1 list
- Page 14 and 15:
XMLDOM model (memory footprint and
- Page 16 and 17:
⋮A configuration section handler
- Page 18 and 19:
managed application, you must first
- Page 20 and 21:
Figure 1-1: Streams can be read and
- Page 22 and 23:
abstraction and explicitly indicate
- Page 24 and 25:
The XPath Query EngineXPath is a la
- Page 26 and 27:
Chapter 2: XML ReadersIn the Micros
- Page 28 and 29:
Table 2-1: Public Properties of the
- Page 30 and 31:
Table 2-3: Public Methods of the Xm
- Page 32 and 33:
Table 2-4: Types of Nodes in the Xm
- Page 34 and 35:
To produce these results, I created
- Page 36 and 37:
In particular, the XmlConvert class
- Page 38 and 39:
The method we create to do this is
- Page 40 and 41:
Consider the following attribute va
- Page 42 and 43:
An entity reference consists of the
- Page 44 and 45:
The NameTable ObjectOne of the secr
- Page 46 and 47:
End ClassByVal type As XmlNodeType)
- Page 48 and 49:
Fragments and Parser ContextThe con
- Page 50 and 51:
You can specify other settings for
- Page 52 and 53:
FullerAndrewSales ManagerLeverlingJ
- Page 54 and 55:
String[] m_headerValues;tokensbool
- Page 56 and 57:
get{if(m_readState != ReadState.Int
- Page 58 and 59:
}public override string this[string
- Page 60 and 61:
}}return false;The name of the attr
- Page 62 and 63:
dt.Columns.Add(col);}reader.MoveToE
- Page 64 and 65:
Readers and XML ReadersTo cap off o
- Page 66 and 67:
Chapter 3: XML Data ValidationOverv
- Page 68 and 69:
The XmlValidatingReader Programming
- Page 70 and 71:
The ValidationEventHandler EventThe
- Page 72 and 73:
Figure 3-1: The sample application
- Page 74 and 75:
document, no event is fired, but an
- Page 76 and 77:
valtype = "Auto.XDR";Figure 3-2 sho
- Page 78 and 79:
validator object for further proces
- Page 80 and 81:
);This method creates and adds a ne
- Page 82 and 83:
public XmlValidatingReader(Stream,
- Page 84 and 85:
XML InteroperabilityAs you can see,
- Page 86 and 87:
XSDs are more powerful than DTDs, a
- Page 88 and 89:
Compared to the DTD schema, this XD
- Page 90 and 91:
xmlns:z='#RowsetSchema'>This simple
- Page 93 and 94:
Figure 3-7: The XSD type hierarchy.
- Page 95 and 96:
Table 3-6: Mapping Between XSD and
- Page 97 and 98:
Table 3-7: Top-Level Elements for X
- Page 99 and 100:
The next step is to define a new sc
- Page 101 and 102:
Creating an XML Schema with Visual
- Page 103 and 104:
Figure 3-10: The graphical represen
- Page 105 and 106:
Open the XML readerXmlTextReader re
- Page 107 and 108:
Define the pattern for the contentX
- Page 109 and 110:
ody of the element. It is a simple
- Page 111 and 112:
determine the correct sequence and
- Page 113 and 114:
The root element can't be successfu
- Page 115 and 116:
Francesco Balena's Programming Visu
- Page 117 and 118:
}sw.Write(sb.ToString());sw.Close()
- Page 119 and 120:
What the XmlWriter Class Can't DoAl
- Page 121 and 122:
stream. Some working memory is free
- Page 123 and 124:
Table 4-5: Miscellaneous Writing Me
- Page 125 and 126:
If you want to get just the default
- Page 127 and 128:
else you might need that the writer
- Page 129 and 130:
By using the pubid argument (PUBLIC
- Page 131 and 132:
Figure 4-3: A dynamically created X
- Page 133 and 134:
This command executes normally, but
- Page 135 and 136:
"dinoe:isbn-0735618011");This code
- Page 137 and 138:
writer.WriteStartElement("element")
- Page 139 and 140:
}writer.WriteEndDocument();writer.C
- Page 141 and 142:
}}reader.Close();If in this code yo
- Page 143 and 144:
Figure 4-8: A PictureBox control di
- Page 145 and 146:
NoteThe entire source code for a sa
- Page 147 and 148:
Table 4-8: Public Methods of the Xm
- Page 149 and 150:
}Writer.WriteStartElement("xml");Wr
- Page 151 and 152:
Testing the XmlRecordsetWriter Clas
- Page 153 and 154:
Framework type and map each to an e
- Page 155 and 156:
}if (i % 2)writer.WriteNode(reader,
- Page 157 and 158:
Table 4-9: Methods of the XmlTextRe
- Page 159 and 160:
while(rw.Read()){switch(rw.NodeType
- Page 161 and 162:
if (m_reader.HasAttributes){// Cons
- Page 163 and 164: Figure 4-14: The code can be used t
- Page 165 and 166: }}rw.Writer.WriteStartElement(rw.Re
- Page 167 and 168: Note The new keyword is C#-specific
- Page 169 and 170: }The net effect of this code is tha
- Page 171 and 172: .NET XML writers only ensure the we
- Page 173 and 174: Part II: XML Data ManipulationChapt
- Page 175 and 176: 3JanetLeverlingWhen processed by an
- Page 177 and 178: child elements when processing an X
- Page 179 and 180: through the base class XmlNode. (Se
- Page 181 and 182: Table 5-3: Events of the XmlDocumen
- Page 183 and 184: Both XmlLinkedNode and XmlCharacter
- Page 185 and 186: Figure 5-3: The XmlLinkedNode class
- Page 187 and 188: Working with XML DocumentsTo be ful
- Page 189 and 190: }}{if (n.NodeType == XmlNodeType.El
- Page 191 and 192: While the secondary thread works, t
- Page 193 and 194: Limitations of the XML DOM Eventing
- Page 195 and 196: XML document is often overkill unle
- Page 197 and 198: If you use a namespace, you might r
- Page 199 and 200: Extending the XML DOMAlthough the .
- Page 201 and 202: Table 5-6: Programming Interface of
- Page 203 and 204: file changes, irrespective of the c
- Page 205 and 206: Figure 5-7: The sample application
- Page 207 and 208: Chapter 6: XML Query Language and N
- Page 209 and 210: Figure 6-1: A sample XML tree in wh
- Page 211 and 212: with the forward slash (/). The fol
- Page 213: How XPointer Uses XPathAn XPointer
- Page 217 and 218: StringBuilder sb = new StringBuilde
- Page 219 and 220: Figure 6-4: The node set returned b
- Page 221 and 222: A Better Way to Select a Single Nod
- Page 223 and 224: 3. Optionally, precompile the XPath
- Page 225 and 226: Table 6-3: Properties of the XPathN
- Page 227 and 228: the type. In addition, attributes a
- Page 229 and 230: As you can see, several methods hav
- Page 231 and 232: Setting Namespace InformationThe in
- Page 233 and 234: string strX = (string) x;string str
- Page 235 and 236: the navigator's author must careful
- Page 237 and 238: ⋮Notice that the sample file syst
- Page 239 and 240: Table 6-10: Properties of the XPath
- Page 241 and 242: supplies the underlying means to id
- Page 243 and 244: • XSL Formatting Objects (XSL-FO)
- Page 245 and 246: HTML," on page 299. In the meantime
- Page 247 and 248: Table 7-2: XSLT Instructions for Da
- Page 249 and 250: Table 7-4: XSLT Instructions for La
- Page 251 and 252: In the first template, the context
- Page 253 and 254: ……⋮The expected target schema
- Page 255 and 256: By the way, note that the version a
- Page 257 and 258: The XslTransform ClassNow that we'v
- Page 259 and 260: To avoid threading risks, be aware
- Page 261 and 262: index of the style sheet contents.
- Page 263 and 264: Table 7-7: Transform Method Overloa
- Page 265 and 266:
XSLT Output RecordsThe output of th
- Page 267 and 268:
Perform the transformation, record
- Page 269 and 270:
method, other attributes of interes
- Page 271 and 272:
Table 7-8: Methods of the XsltArgum
- Page 273 and 274:
the object's DataSetName property.
- Page 275 and 276:
s:rowbaseAfter you create the node
- Page 277 and 278:
features than the XslTransform clas
- Page 279 and 280:
Don't confuse the Internet Explorer
- Page 281 and 282:
Supported languages are C#, Visual
- Page 283 and 284:
double CalculateSubTotal(XPathNodeI
- Page 285 and 286:
profitable, because XML is a metala
- Page 287 and 288:
Chapter 8: XML and DatabasesOvervie
- Page 289 and 290:
Framework applications. SQLXML 3.0
- Page 291 and 292:
......The FOR XML AUTO mode always
- Page 293 and 294:
Figure 8-1: The client-side XML for
- Page 295 and 296:
lastname AS [Employee!1!Name]This s
- Page 297 and 298:
sql:field="FirstName" type="xsd:str
- Page 299 and 300:
to instantiate a COM object, query
- Page 301 and 302:
}// Process elementswhile(reader.Re
- Page 303 and 304:
(No context information specified)X
- Page 305 and 306:
}...The base class is for the most
- Page 307 and 308:
public override void Close(){m_data
- Page 309 and 310:
Synchronizing with a DataSet Object
- Page 311 and 312:
denote insertions, deletions, and u
- Page 313 and 314:
schema information to associate the
- Page 315 and 316:
This schema first defines a relatio
- Page 317 and 318:
that throughout the Updategram. The
- Page 319 and 320:
object for XML-driven updates, an A
- Page 321 and 322:
Table 8-2: Properties of the SqlXml
- Page 323 and 324:
Table 8-4: Methods of the SqlXmlCom
- Page 325 and 326:
This schema addresses a layout such
- Page 327 and 328:
database. If all goes well, the Dat
- Page 329 and 330:
Chapter 9: ADO.NET XML Data Seriali
- Page 331 and 332:
provided way to serialize ADO.NET o
- Page 333 and 334:
1DavolioNancy⋮106897⋮Basically,
- Page 335 and 336:
The element describes the body of
- Page 337 and 338:
Serializing to Valid XMLAs you can
- Page 339 and 340:
Table 9-3: The MappingType Enumerat
- Page 341 and 342:
⋮This syntax is simple and effect
- Page 343 and 344:
By using keyref and nested types, y
- Page 345 and 346:
Figure 9-6: An application that pas
- Page 347 and 348:
{}DataTable dt = CreateTempTable(dv
- Page 349 and 350:
dt = (DataTable) bf.Deserialize(sr.
- Page 351 and 352:
more valuable, because it automatic
- Page 353 and 354:
Loading DataSet Objects from XMLThe
- Page 355 and 356:
The XML source is read one node aft
- Page 357 and 358:
Figure 9-10: ReadXml correctly reco
- Page 359 and 360:
Figure 9-12: How Microsoft Visual S
- Page 361 and 362:
The reader tracks the current node
- Page 363 and 364:
}m_currentAttributeIndex = -1;When
- Page 365 and 366:
persistence, resort to the DiffGram
- Page 367 and 368:
......The root node can have up to
- Page 369 and 370:
object's tables. The data written o
- Page 371 and 372:
different blocks. Attributes in the
- Page 373 and 374:
If no match is found, ReadXml deduc
- Page 375 and 376:
Although this solution is clearly n
- Page 377 and 378:
The diffgr:error attribute on the r
- Page 379 and 380:
{}// Url is a form property that po
- Page 381 and 382:
...By design, the current DiffGram
- Page 383 and 384:
a DiffGram. To make DiffGrams reall
- Page 385 and 386:
Figure 10-8: The sample save-and-re
- Page 387 and 388:
dv.RowStateFilter = DataViewRowStat
- Page 389 and 390:
in the RowError property of the cor
- Page 391 and 392:
however, the verbosity of XML paten
- Page 393 and 394:
Chapter 11: XML SerializationOvervi
- Page 395 and 396:
0As you can see, the class represen
- Page 397 and 398:
ead-only properties; does not handl
- Page 399 and 400:
}public Employee(){m_ID = -1;}publi
- Page 401 and 402:
Methods of the XmlSerializer ClassT
- Page 403 and 404:
ns.Add("d", "urn:dino-e-xml");ns.Ad
- Page 405 and 406:
When designing classes destined to
- Page 407 and 408:
eferenced assembly and its properti
- Page 409 and 410:
The preceding code creates an attri
- Page 411 and 412:
}public string FirstName;public str
- Page 413 and 414:
XML as the type dictates. The attri
- Page 415 and 416:
create the XmlSerializer object. Ho
- Page 417 and 418:
command, the data flows into the se
- Page 419 and 420:
XmlAttributes changesFirstName = ne
- Page 421 and 422:
{if (emp.Territories == null)emp.Te
- Page 423 and 424:
{// Import type mapping information
- Page 425 and 426:
As you can see, the first file crea
- Page 427 and 428:
A good source for learning about SO
- Page 429 and 430:
NoteSome programmers believe that .
- Page 431 and 432:
involved, you must use Web services
- Page 433 and 434:
handled by .NET Remoting; the user
- Page 435 and 436:
Figure 12-3: How .NET Remoting mars
- Page 437 and 438:
If you want to play with the transp
- Page 439 and 440:
The query involves three tables—E
- Page 441 and 442:
As we saw in Chapter 4, the XmlText
- Page 443 and 444:
{// Propertiesprotected SalesDataPr
- Page 445 and 446:
We'll look more closely at channels
- Page 447 and 448:
server only when the client calls a
- Page 449 and 450:
Figure 12-5: The IIS application ma
- Page 451 and 452:
this little requirement is enough t
- Page 453 and 454:
typeof(ServiceSalesProvider),"tcp:/
- Page 455 and 456:
}The code in boldface demonstrates
- Page 457 and 458:
BinaryWriter writer = new BinaryWri
- Page 459 and 460:
Chapter 13: XML Web ServicesOvervie
- Page 461 and 462:
intSOAP is not magic—it is a simp
- Page 463 and 464:
public class MyWebService : WebServ
- Page 465 and 466:
effectively exposed over the Web, a
- Page 467 and 468:
Format of SOAP Messages for a Web M
- Page 469 and 470:
The SoapRpcMethod AttributeThe RPC
- Page 471 and 472:
If you compare this code with the r
- Page 473 and 474:
Figure 13-5: Processing a Web servi
- Page 475 and 476:
The machine.config file is an XML f
- Page 477 and 478:
Namespace="xmlnet/cs/0735618011")]p
- Page 479 and 480:
In situations in which the URL can'
- Page 481 and 482:
Const TheYear = 1997' Create the HT
- Page 483 and 484:
implementation does make a lot of s
- Page 485 and 486:
Mobile code allows you to send C# o
- Page 487 and 488:
Chapter 14: XML on the ClientOvervi
- Page 489 and 490:
accessible XML parser to consume th
- Page 491 and 492:
The following code shows a version
- Page 493 and 494:
NoteIn general, you can name the ou
- Page 495 and 496:
To create a hidden field, you can u
- Page 497 and 498:
To load assemblies from directories
- Page 499 and 500:
{}int size = 130;this.Columns.Add(m
- Page 501 and 502:
private void PrepareSortedDataView(
- Page 503 and 504:
Figure 14-3: An ASP.NET page that c
- Page 505 and 506:
var parser = new ActiveXObject("Mic
- Page 507 and 508:
"SERVER=localhost;DATABASE=northwin
- Page 509 and 510:
Chapter 15: .NET Framework Applicat
- Page 511 and 512:
Because we're focusing on applicati
- Page 513 and 514:
executable, ASP.NET application or
- Page 515 and 516:
NoteUser applications don't need to
- Page 517 and 518:
The myfile.config file contains the
- Page 519 and 520:
Some internal variablesXmlNodeList
- Page 521 and 522:
scratch or inherit from an existing
- Page 523 and 524:
Table 15-2: Predefined Section Hand
- Page 525 and 526:
The interface includes a single met
- Page 527 and 528:
NameValueCollection coll;coll = Con
- Page 529 and 530:
}if (configMenu != null)AddMenuTool
- Page 531 and 532:
}}menuTools.MenuItems.Add(index, mn
- Page 533 and 534:
Implementing the DataSet Section Ha
- Page 535 and 536:
AfterwordOverviewWhile writing this
- Page 537:
not an application-specific object.