1 / 31

XML Fundementals

XML Fundementals. XML vs.. HTML XML Document (elements vs. attributes) XML and RDBMS XML Schema (DTD; XSD) XPATH XSLT (XSL; XSLT) SYSTEM.XML XSD Classes and Types Serialization Process. HTML. Any need for re-query or sorting of existing data required a new round-trip to the server.

sema
Download Presentation

XML Fundementals

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. XML Fundementals • XML vs.. HTML • XML Document (elements vs. attributes) • XML and RDBMS • XML Schema (DTD; XSD) • XPATH • XSLT (XSL; XSLT) • SYSTEM.XML • XSD Classes and Types • Serialization Process

  2. HTML Any need for re-query or sorting of existing data required a new round-trip to the server.

  3. HTML vs. XML HTML and XML are both “firewall friendly” XML separate data from presentation XML is not a markup language XML defines the data content and structure <?xml version="1.0" encoding="utf-8" ?> <CUSTOMERSORDERS> <CUSTOMERS CustomerID="ALFKI" CompanyName="Alfreds Futterkiste" ContactName="Alfreds Futterkiste" ContactTitle="Sales Representative" Phone="030-0074321"> <ORDERS OrderID="10643" OrderDate="2000-08-25T00:00:00"/> <ORDERS OrderID="10692" OrderDate="2000-10-03T00:00:00"/> <ORDERS OrderID="10702" OrderDate="2000-10-13T00:00:00"/> <ORDERS OrderID="10835" OrderDate="2001-01-15T00:00:00"/> <ORDERS OrderID="10926" OrderDate="2001-03-04T00:00:00"/> <ORDERS OrderID="10952" OrderDate="2001-03-16T00:00:00"/> <ORDERS OrderID="11011" OrderDate="2001-04-09T00:00:00"/> </CUSTOMERS> <CUSTOMERS CustomerID="ANATR" CompanyName="Ana Trujillo Emparedados y helados" ContactName="Ana Trujillo" ContactTitle="Owner" Phone="(5) 555-4729"> <ORDERS OrderID="10759" OrderDate="2000-11-28T00:00:00"/> </CUSTOMERS> </ CUSTOMERSORDERS >

  4. Anatomy of XML Document • <?xml version="1.0" encoding="utf-8"?> • <!DOCTYPE books SYSTEM “books.dtd”> • <?xml-stylesheet type="text/xsl“ href="books.xsl" ?> • <books xmlns=“http://schema.mycomp.com/books” xmlns:uk=“xxxxxx” > • <bookisbn="0-00-649845-0“ > • <title> Op-Centre</title> • <author>Steve Pieczenik</author> • <price>25.99</price> • </book> • <bookisbn="0-201-63361-2"> • <title>Design Patterns</title> • <author>Erich Gamma</author> • <author>Richard Helm</author> • <author>Ralph Johnson</author> • <uk:price>34.00</uk:price> • </book> • </books>

  5. Creating XML Documents Legacysystems XML document Relational databases ServerPages OtherXMLdocuments Messages

  6. The hierarchical nature of XML <books> <book isbn="0-00-649845-0"> <title>Op-Centre<title><author>Steve Pieczenik</author> <price>25.99</price> </book> <book isbn="0-201-63361-2"> <title>Design Patterns</title><author>Erich Gamma</author> <price>59.00</price> </book> <book isbn="0-201-63361-2"> <title>Design Patterns</title><author>Ralph Johnson</author> <price>59.00</price> </book> <book isbn="0-201-63361-2"> <title>Design Patterns</title><author>Ralph Johnson</author> <price>59.00</price> </book></books> <books> <book isbn="0-00-649845-0"> <title>Op-Centre<title><author>Steve Pieczenik</author> <price>25.99</price> </book> <book isbn="0-201-63361-2"> <title>Design Patterns</title><author>Erich Gamma</author> <author>Richard Helm</author> <author>Ralph Johnson</author> <price>59.00</price> </book> </books>

  7. Hierarchical support in relational databases 1/2 SELECT Books.isbn, Books.title, Authors.name as 'author', Books.price FROM Books, BooksAuthors, Authors WHERE Books.isbn = BooksAuthors.isbn and BooksAuthors.AuthorID = Authors.AuthorID • How would you? • Add new Author that has no book’s isbn yet. • Remove the ‘0-00-649845-0’ row but keep the author ‘Steve Pieczenik’. • Change the title ‘Design Patterns’ without having to do it in many places. ‘Books’ table ‘Authors’ table ‘BooksAuthors’ table

  8. Hierarchical support in relational databases 2/2 Select Books.*, Authors.name as Authors from Books, BooksAuthors, Authors where Books.isbn = BooksAuthors.isbn and BooksAuthors.AuthorID = Authors.AuthorID order by Books.isbn for xml auto

  9. XML Schema • DTD (Old W3C standard, supported by all …) • XDR (Microsoft only) • XSD (W3C standard as of May 2001)

  10. Bookstore DTD - Sample <!ELEMENT books (book*)> <!ELEMENT book (title, author+, price)> <!ATTLIST book isbn CDATA #REQUIRED> <!ELEMENT title (#PCDATA)> <!ELEMENT author (#PCDATA)> <!ELEMENT price (#PCDATA)> DEMO – Validating XML with DTD

  11. Bookstore XSD - Sample • Open Sample

  12. Using XSLT Capabilities • An XSLT style sheet can perform a wide range of transformations • Examples: • Map one XML grammar to another • Filter unwanted data • Sort XML data • Restructure an XML document • Perform computations

  13. Transforming XML into a Different XML Grammar XML document Different XML grammar + XSLT processor XSLT style sheet <employees> <employee> <name>Reid</name> <salary>91000</salary> </employee> … </employees> <staff> <staff-member name="Reid" pay="91000"/> … </staff>

  14. Transforming XML into HTML XML document XHTML document (XML compliant) + XSLT processor XSLT style sheet <employees> <employee> <name>Reid</name> <salary>91000</salary> </employee> … </employees> <HTML><TABLE> <TR> <TD>Reid</TD> <TD>91000</TD> </TR> … </TABLE></HTML>

  15. What Is XPath? • XPath maps an XML document to a tree of nodes • Use XPath expressions to identify, select, and manipulate nodes in an XML hierarchy • Use location paths to select nodes • XPath operators and functions

  16. XPath XML XML XML Why Use XPath? In XSLT style sheets,for pattern matching System.xml to selectnodes programmatically XPath In XPointer, to link documents together In SQL Server 2000,to address result-set nodes

  17. Using XSLT on the Server • Apply a stylesheet to a document on the server • Transform between different schemas • Merge data sources • Conversion based on business processes and requirements • Convert XML into well-formed HTML Another server XSLT Different XML grammar Other browser XML XSLT HTML IE5 client XSLT XML

  18. SYSTEM.XML • Hello System.Xml • Quick overview - libraries tools and goals. • Integrating XML into your applications. • XML & Performance = streaming-based model • XML Transformation with performance in mind. • Demo • Optional: Accessing Raw SOAP Messages in ASP.NET Web Services • Hierarchical vs. Relational representation of data. • Why do we need them both. • XML Integration with Relational Data. • Demo

  19. Hello System.Xml • System.Xml • System.Xml.Schema • System.Xml.Serialization • System.Xml.XPath • System.Xml.Xsl Tools xsd.exe Xml schema designer Data Adapter Wizard External tools Design Goals Compliance with the W3C standards Extensibility Pluggable architecture Performance Tight integration with ADO.NET

  20. XML & Performance = streaming-based model • XmlReader • Minimal caching for forward-only pull model parsing. • XmlValidatingReader • Forward-only validation. • XPathNavigator • cursor style navigation • minimizes node creation to a single virtual node • yet provides random access to the document. • does not require a complete node tree to be built in memory (DOM) • XslTransform • Incremental streaming output.

  21. XML Transformation with performance in mind

  22. XML Transformation with performance in mind

  23. Hierarchical vs. Relational representation of data

  24. Hierarchical vs. Relational representation of data

  25. Hierarchical vs. Relational representation of data • Discussion: Why do we need them both?

  26. XML Integration with Relational Data and ADO.NET

  27. XML Integration with Relational Data and ADO.NET

  28. Synchronizing a DataSet with an XmlDataDocument Sample Code …

  29. Serialization Process • Classes used by the default Serialization Process • Classes used with Serialized Streams, File Stream, Memory Stream, Net Stream • Binary Formatter • SOAP Formatter • De-serialization

  30. XSD Classes and Types • Using xsd.exe to generate schema from classes • Using xsd.exe to generate classes from schema • XSD Types • Demo

  31. Review • XML vs.. HTML • XML Document (elements vs. attributes) • XML and RDBMS • XML Schema (DTD; XSD) • XPATH • XSLT (XSL; XSLT) • SYSTEM.XML • XSD Classes and Types • Serialization Process

More Related