1 / 9

XML, eXtensible Markup Language (1)

The format for structured information exchange. Primary structuring is containment and sequence. A valid XML document is a tree. <?xml version="1.0"?> <purchaseOrder orderDate="1999-10-20"> <shipTo country="US"> <name>Alice Smith</name> <street>123 Maple Street</street>…

stacy-crane
Download Presentation

XML, eXtensible Markup Language (1)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The format for structured information exchange. Primary structuring is containment and sequence. A valid XML document is a tree <?xml version="1.0"?> <purchaseOrder orderDate="1999-10-20"> <shipTo country="US"> <name>Alice Smith</name> <street>123 Maple Street</street>… </shipTo> <billTo country="US"> <name>Robert Smith</name> … </billTo> <comment>Hurry, my lawn is going wild! </comment> <items> <item partNum="872-AA"> <productName>Lawnmower </productName> <quantity>1</quantity> <USPrice>148.95</USPrice> <comment>Confirm this is electric</comment> </item> <item partNum="926-AA">… </items> </purchaseOrder> XML, eXtensible Markup Language (1)

  2. XML tree structure Root purchaseOrder items billTo comment @orderDate shipTo … item item state street @country @country street state … name name city city zip zip quantity comment @partNum shipDate USPrice productName 123 Maple Street 8 Oak Avenue Hurry, my lawn is going wild! PA US CA US 1999-05-21 148.95 Lawnmower Alice Smith 90952 Old Town Confirm this is electric 872-AA 1999-10-20 Mill Valley Robert Smith 95819 1

  3. XML document

  4. <?xml version="1.0"?> <purchaseOrder orderDate="1999-10-20"> <shipTo country="US"> <name>Alice Smith</name> <street>123 Maple Street</street>… </shipTo> <billTo country="US"> <name>Robert Smith</name> … </billTo> <comment>Hurry, my lawn is going wild!</comment> <items> <item partNum="872-AA"> <productName>Lawnmower </productName> <quantity>1</quantity> <USPrice>148.95</USPrice> <comment>Confirm this is electric </comment> </item> <item partNum="926-AA">… </items> </purchaseOrder> The format for structured information exchange. Primary structuring is containment and sequence. A valid XML document is a tree Extensible – anyone can “coin” markup tags Is an application of SGML, the Structured Markup Language a standard for marking-up documents Can be edited with any text editor XML, eXtensible Markup Language (2)

  5. <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"><xsd:element name="purchaseOrder" type="PurchaseOrderType"/><xsd:element name="comment" type="xsd:string"/><xsd:complexType name="PurchaseOrderType"> <xsd:sequence> <xsd:element name="shipTo" type="USAddress"/> <xsd:element name="billTo" type="USAddress"/> <xsd:element ref="comment" minOccurs="0"/> <xsd:element name="items" type="Items"/> </xsd:sequence> <xsd:attribute name="orderDate" type="xsd:date"/> </xsd:complexType> ….</xsd:schema> Defines a class of documents Allowed structure, content and constraints An XML document can be an instance of the schema class Uses XML syntax Can use XML tools to process it Has a large set of pre-defined simple data-types that can be extended. Instances can be validated against the schema XML Schema

  6. XML in document exchange <tag>...</tag> Standard database XML XML LineItem database table: <Product><ID>Lawnmower 872-AA</ID> </Product> <ProductName>Lawnmower </ProductName> <PartNumber>872-AA </PartNumber> LineItem database table:

  7. Database and database schema Movie (movieName, releaseYear, director) Starred (movieName, actor) Movie: Starred: Example based on p. 5 of “Information Modeling and Relational Databases” by Terry Halpin, 2001

  8. Questions 3.1 That completes the topic of XML, now for some questions: • What is one of the primary purposes of XML? • What is one of the primary purposes of XML Schema? • What do databases and XML have in common?

  9. Answers 3.1 • What is one of the primary purposes of XML? • To exchange structured data • What is one of the primary purposes of XML Schema? • To define a class of documents • To validate an XML document as an instance of the class • What do databases and XML have in common? • Structured information • Schemas • Constraints

More Related