Đề tài Creating SQL Server 2005 Express Applications
Continuing, you now see a nested element known as Customer, whose start tag is <Customer> and end tag is </Customer>. This element itself contains two nested elements, one known as Name, and the other known as Identifier. It also contains a nested element known as Instructions. This element and those nested within it appear to be a little confusing, though. What’s going on? Looking at the XML document listed earlier in the chapter, you may wonder how your computer can keep things straight when handling XML received from different sources. For example, what happens if you receive purchase orders from two different organizations that use different element names and attributes that actually mean the same thing? Conversely, what happens if they use identical element names and attributes that mean different things? This situation is where namespaces comes to the rescue. Typically available for consultation and review via the Internet, namespaces are assemblages of element type and attribute names that help establish order and clear up confusion. By providing a solid point of reference, they also assist when merging smaller subsets of XML documents. In this case, the document includes a link to a namespace server: <reg:Instructions xmlns:reg=”http://www.samplenamespace.com/importexport”> By specifying this namespace server, any applications that use this XML document consult the namespace server for details about any elements or attributes prefixed with reg. A second namespace server comes up a little later in the XML. <Creator>Michael McManus</Creator> Here’s an example of an element that tracks the purchase order’s creator. It has no nested elements within; it is, however, nested within the purchase order element itself. <Product quantity=”1” price=”9.99”>GG2911</Product> <Product quantity=”6” price=”54.94”>TK3020</Product> Now you can see additional elements, both known as Product. These elements have their own attributes, quantity and price in this case. <ship:Shipment xmlns:ship=”http://www.samplenamespace.com/shipping”> <ship:ShipDate>6/10/2007</ship:ShipDate> <ship:Instructions>Contact Mr. Hockney in receiving</ship:Instructions> <ship:Instructions>Fax bill to Mr. Kobayashi</ship:Instructions> </ship:Shipment>
Các file đính kèm theo tài liệu này:
- microsoft_sql_server_2005_express_edition_for_dummies00009_4913.pdf