1 / 44

Adam Cogan

eXtensible Markup Language (XML). Adam Cogan. About Adam. Developer - experience with: internal corporate development and generic off-the-shelf databases Clients: Tennis Australia, Cabletron, Cisco…. President - Access /ASP/SQL Server User Group, Sydney Speaker for Microsoft Roadshows

celeste
Download Presentation

Adam Cogan

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. eXtensible Markup Language (XML) Adam Cogan

  2. About Adam • Developer - experience with: • internal corporate development and • generic off-the-shelf databases • Clients: Tennis Australia, Cabletron, Cisco…. • President - Access/ASP/SQL Server User Group, Sydney • Speaker for Microsoft Roadshows • Email: adamcogan@ssw.com.au

  3. … Agenda • Why do we need XML? • XML Overview • XML Structure • Validation • Using XML • Data binding for the web • XSL • VBA Applications (Using Document Object Model) • XML for n-tier

  4. … What is the Problem? • Applications cannot understand other applications data. • Laying out data on documents, web pages and forms has to be custom. • There is no universal standard for data structure.

  5. What is an Example?… • Let's say you receive an email and wish to save the contact information of the sender. Generally, you would copy the text about the sender and paste it in an application. • To use the contact information in Outlook, you would paste each part of the contact data into the appropriate field. • To use the contact in Word you would past the text in Word. • To do a bar graph showing what city your contacts reside in the data would be moved to Excel.

  6. The Solution - XML … • With XML, all of these application could understand and use the data easily. • XML makes it easy for different people using different kind of software to understand and exchange information.

  7. … Fundamentals • XML is not an application. • A browser simply reads a text stream and displays it in the browser. • HTML will format the text that is shown in the document (e.g. make the text bold). • <B> Adam </B> • XML describes the data in a document or web page. • <FirstName> Adam </FirstName>

  8. … XML vs HTML • HTML is all about display! • XML is all about data! • HTML can contain XML - and vice versa

  9. … XML – The Standard • XML is a W3C standards-based text format for interchange of data • http://www.w3.org/TR/REC-xml • Why wasn’t ASCII and CSV good enough?

  10. Simple Date Example … • XML defines data, not display. • HTML defines the formatting of text. • HTML can make text appear bold: • <B>May 10, 2000</B> • HTML defining some text - but giving no meaning to it • <OrderDate Format = “long”>May 10, 2000 </OrderDate> • XML defining a date, but not saying how it should be displayed • Elements – Attributes - DTD

  11. Business Card Example … <BusinessCard> <Name> <FirstName>Adam</FirstName> <LastName>Cogan</LastName> </Name> <Address> <Address>101 SW Fifth</Address> <City>Neutral Bay, NSW, 2087</City> </Address> <Phone> <Home>9953 3000</Home> <Mobile>04 1985 1995</Mobile> </Phone> </BusinessCard>

  12. … XML andData • XML can represent regular, relational record-style data • It can also represent hierarchical data • It can, of course, represent irregular data too

  13. … Invoice Example <Invoice> <From>C. Brooks. </From> <To>C. McCall </To> <Date>2/1/99 </Date> <Amount>$189.00 </Amount> <Tax>10% </Tax> <Total>$207.90</Total> </Invoice>

  14. … Making It Work • XML File – for the data • XSL File – Style sheet for the XML • Add the "Processing Instruction" at the top of the XML file • In-Line XML

  15. … A Typical Document • What does every document consist of? • Data - the words or content of the document. • Presentation - the way information is presented to the user of the document. Fonts, style, color. • Structure - consists of type and elements. • Type - Memo, Invoice, PO, License, etc. • Elements - Name, Amount, License #

  16. Traditional WYSIWYG Document XML Document Presentation XSL Presentation Content Content XML Structure XML No Real Structure … XML Components

  17. XML - Six Things to Know … • Start and End Tags • Entity References • Attribute Assignments • Comments • Processing Instructions • Document Type Declarations (Schema-Future)

  18. Start and End Tags … • Must be a matched set – Opening and closing tags required: <greeting></greeting> • No spaces allowed : <PC Brand> • Can’t begin with a number: <3Topic> • No spaces in end tag: </ greeting>

  19. Entity References (Your Data!) … • An entity is a unit of text that can be inserted into the XML document. • XML entities can reference a single character or an entire novel of data. • There are two types of entities - default and defined. • <BirthDate> • 20/2/1973 • </BirthDate> • <BirthDate> • 20/2/1973 • </BirthDate>

  20. Attribute Assignment … • Allows you to describe the type of data your are dealing with. • [name of attribute] “=“ [value] • <greeting language=“French”> • Must be in quotes. • Multiple attributes are supported. • This works exactly the same as in HTML

  21. … Comments • XML comments use the exact same form as HTML comments: <!– My Comment -->

  22. … Processing Instructions • Allows XML to store application specific information. • Must be in the declaration section of the document. • Three main types: • <?xml version = “1.0”?> • DTD • Style Sheet

  23. … Document Type Declaration • Allows you to instruct the parser, where to find the DTD: • <!DOCTYPE type LOCATION “path”> • <!DOCTYPE HTML PUBLIC “//goose/example.dtd”>

  24. … Create Your Own XML • Creating XML file manually • Create XML file with ADO 2.5

  25. XML Data-Schemas • The Microsoft ADO implementation. • A way to describe the structure, content and data type of XML-data. • Extends the functionality of DTD's. • Uses an XML Grammer. • Can be used to validate XML. • Currently Microsoft only technology.

  26. XML Validation-DTD … • XML - Works with DTD, “Document Type Definition”, and the data to provide and define “structure”. • XML ‘Applications’ • Industry Standards have begun to develop. • Allows an industry to choose a standard format for data exchange

  27. XML Validation-XML Applications … • Industry members agreeing on a set of tags for Validation • RealML (Real Estate) • BizTalk • OFX (Open Financial Exchange Format) • Download Technology • MathML • ChemML • CDF (Channel Definition Format)

  28. … XML Validation XML Doc. XML Parser XML Client XML DTD

  29. … Parsing XML into Nodes Document root Comment customer list customer customer ID ID 345 120 name orders first last order order date date Jane Doe 1998-07-16 1998-07-23

  30. Document Object Model (DOM) … mydocument Document root root Customer Customer ID ID bar baz 123 456 345 • root = mydocument.documentElement;

  31. Document Object Model (DOM) … mydocument Document node root root Customer Customer ID ID bar baz 123 456 345 • root = mydocument.documentElement; • node = root.childNodes.item(1);

  32. Document Object Model (DOM) … mydocument Document node root root Customer Customer ID ID bar baz 123 456 8910 update • root = mydocument.documentElement; • node = root.childNodes.item(1); • node.childNodes.item(0).nodeValue = “8910”;

  33. Document Object Model (DOM) … mydocument Document node root root attr Customer Customer ID ID bar baz 123 456 8910 update • root = mydocument.documentElement; • node = root.childNodes.item(1); • node.childNodes.item(0).nodeValue = “8910”; • attr = node.attributes.getNamedItem(“ID”);

  34. newNode Document Object Model (DOM) … mydocument Document node root root attr Customer Customer ID ID bar baz 123 456 8910 update • root = mydocument.documentElement; • node = root.childNodes.item(1); • node.childNodes.item(0).nodeValue = “8910”; • attr = node.attributes.getNamedItem(“ID”); • root.insertBefore(newNode,root.firstChild);

  35. newNode Document Object Model (DOM) … mydocument Document root root Customer ID bar 123 456 • root = mydocument.documentElement; • node = root.childNodes.item(1); • node.childNodes.item(0).nodeValue = “8910”; • attr = node.attributes.getNamedItem(“ID”); • root.insertBefore(newNode,root.firstChild); • root.removeNode(root.lastChild);

  36. DOM

  37. … Working With XML Files and Recordsets • Data from a database saved as XML • Retrieve XML data and display in grid • Retrieve XML data and save to a database

  38. … XML Data Binding • Using Data Binding with IE 5.

  39. … Using XML - XSL • XSL – Extensible Style Language provides the formatting and presentation. • Can filter, sort and layout XML. • Apply filters and sorts dynamically.

  40. Demo-XML and ASP and ADO • Build XML using vb script or Java script • Update data using XML DOM

  41. Summary: XML why is it so cool? • EASY and Powerful! • Standard way to represent data • Abstraction and Ubiquity with Robustness • End-to-end (standard) data protocol • Standard data protocol from Tier 3 to Tier 2 • Standard data protocol from Tier 2 to Tier 1 • Express data in format that only requires HTTP (See ‘XML for n-Tier’ session coming up) • Rich Object Model (DOM) in Windows, Java • Cross Platform: Parsers for every OS around • Including Windows, Linux, Unix, Mac, CE, PalmOS

  42. XML Suggested Readings • Chapter 27 - Access 2000 Development Unleashed (SAMS Publishing) • MSDN • XML Programming With VB and ASP (Manning Publishing) • XML IE5 Programmers Reference (WROX Press) • Examples at www.ssw.com.au

  43. Questions and Answers

  44. THANK YOU!

More Related