Presentation XML. NET SEMINAR By: Siddhant Ahuja (SID)

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
XML & Data Structures for the Internet Yingcai Xiao.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-1 COS 346 Day 24.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-1 COS 346 Day 25.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-1 COS 236 Day 23.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
XSL Transformations Transforming XML document into other (XML) documents 1XSL Transformations.
MC 365 – Software Engineering Presented by: John Ristuccia Shawn Posts Ndi Sampson XSLT Introduction BCi.
C# The new language for Updated by Pavel Ježek © University of Linz, Institute for System Software, 2004 published under the Microsoft Curriculum License.
PHP and XML TP2653 Advance Web Programming. PHP and XML PHP5 – XML-based extensions, library and functionalities (current XAMPP PHP version is )
.NET and XML (or XML in.NET) David Oguns Matt Harding.
XML.NET Concepts and Implementation Badar Gillani.
Chapter 12 Creating and Using XML Documents HTML5 AND CSS Seventh Edition.
XML Fundementals XML vs.. HTML XML vs.. HTML XML Document (elements vs. attributes) XML Document (elements vs. attributes) XML and RDBMS XML and RDBMS.
Sheet 1XML Technology in E-Commerce 2001Lecture 6 XML Technology in E-Commerce Lecture 6 XPointer, XSLT.
Introduction to XML cs3505. References –I got most of this presentation from this site –O’reilly tutorials.
XSLT for Data Manipulation By: April Fleming. What We Will Cover The What, Why, When, and How of XSLT What tools you will need to get started A sample.
XML and its applications: 4. Processing XML using PHP.
ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.
ASP.NET and XML Presented By: Shravan S. Mylavarapu 1.
Copyright © Software Insight Querying and Transforming XML with.NET.
School of Computing and Management Sciences © Sheffield Hallam University To understand the Oracle XML notes you need to have an understanding of all these.
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
Introduction to XML Eugenia Fernandez IUPUI. What is XML? From the World Wide Web Consortium (W3C) The Extensible Markup Language (XML) is the universal.
WORKING WITH XSLT AND XPATH
1 © Netskills Quality Internet Training, University of Newcastle Introducing XML © Netskills, Quality Internet Training University.
Intro. to XML & XML DB Bun Yue Professor, CS/CIS UHCL.
LINQ TO XML Mike Taulty Developer & Platform Group Microsoft UK
 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 34 - Case Study: Active Server Pages and XML Outline 34.1 Introduction 34.2 Setup and Message.
XML DOM Functionality in.NET DSK Chakravarthy
JSTL, XML and XSLT An introduction to JSP Standard Tag Library and XML/XSLT transformation for Web layout.
1 XMLXML and.NETNOEA / PQC 2005 (rev. FEN 2007) XML and the.NET framework Heavily inspired by: Support WebCast: Programming XML in the Microsoft.NET Framework.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter X IXXXXXXXXXX XXXXXX.
DAT 379 XML Today And Tomorrow Mark Fussell Lead Program Manager Microsoft Corporation.
Module 7: Accessing Data by Using ADO.NET
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
Schemas 1www.tech.findforinfo.com. What is a Schema a schematic or preliminary plan Description of a structure, details... 2www.tech.findforinfo.com.
Declaratively Producing Data Mash-ups Sudarshan Murthy 1, David Maier 2 1 Applied Research, Wipro Technologies 2 Department of Computer Science, Portland.
Chapter 27 The World Wide Web and XML. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.27-2 Topics in this Chapter The Web and the Internet.
CS 157B: Database Management Systems II February 11 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
Web Technologies Lecture 4 XML and XHTML. XML Extensible Markup Language Set of rules for encoding a document in a format readable – By humans, and –
.NET and XML (or XML in.NET) Matt Harding David Oguns.
1 Introduction JAXP. Objectives  XML Parser  Parsing and Parsers  JAXP interfaces  Workshops 2.
Module 3: Working with Local Data. Overview Using DataSets Using XML Using SQL Server CE.
Accessing XML Documents Using DOM ©NIITeXtensible Markup Language/Lesson 8/Slide 1 of 23 Objectives In this lesson, you will learn to: * Use XML DOM objects.
Martin Kruliš by Martin Kruliš (v1.1)1.
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
Introduction to.NET Building.NET Applications Mike Taulty Developer & Platform Group Microsoft Ltd
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
CIS 228 The Internet 9/20/11 XHTML 1.0. “Quirks” Mode Today, all browsers support standards Compliant pages are displayed similarly There are multiple.
 XML derives its strength from a variety of supporting technologies.  Structure and data types: When using XML to exchange data among clients, partners,
D Copyright © 2004, Oracle. All rights reserved. Using Oracle XML Developer’s Kit.
XSLT, XML Schema, and XPath Matt McClelland. Introduction XML Schema ▫Defines the content and structure of XML data. XSLT ▫Used to transform XML documents.
Apache Cocoon – XML Publishing Framework 데이터베이스 연구실 박사 1 학기 이 세영.
I Copyright © 2004, Oracle. All rights reserved. Introduction.
XML for .NET Session 1 Introduction to XML Introduction to XSLT
XML: Extensible Markup Language
Displaying XML Data with XSLT
XML in Web Technologies
Database Processing with XML
Chapter X IXXXXXXXXXXXXXXXX.
More Sample XML By Sadia Anjum.
04 | Data Acess Technologies
XML and its applications: 4. Processing XML using PHP
More XML XML schema, XPATH, XSLT
Presentation transcript:

Presentation XML. NET SEMINAR By: Siddhant Ahuja (SID)

XML.NET Seminar by Sid Outline 1. Introduction to XML   Mark-up Languages   XML Evolution and W3C 2. XML and Microsoft.NET 3. XML Parsing Models   Common Parsing Models DOM, Forward only Push (SAX)/Pull Model Parsing,  .NET Framework Parsing Models Forward only Pull Model Parsing DOM Parsing   Advantages and Limitations of each 4. Core XML.NET Namespaces

XML.NET Seminar by Sid Outline 5. Dynamically generating XML in.NET   Non-cached, forward only streaming   Programming the DOM   Advantages and Limitations of each 6. Validating XML in.NET   DTD, XDR, XSD   Schemas in.NET 7. Applying Style sheets to XML Documents   XSLT in.NET BREAK: Q/A

XML.NET Seminar by Sid Outline 8. XPath Queries 9. Summary and Q/A

XML.NET Seminar by Sid XML is Born XML and Microsoft. NET Subset of SGML XML is a mark up that describes structure Acts as an integration protocol between applications Industry standard developed by W3C

XML.NET Seminar by Sid Introduction to XML Intro Mark up is: Adding Meaning to the Text Changing format of the Text Example: Sid

XML.NET Seminar by Sid Making an XML file Intro Windows XP SP2 This is the latest update pack provided by Microsoft. Has Firewall Protection Free ~200 MB for Windows XP Home Edition

XML.NET Seminar by Sid XML on the Web Intro

Windows XP SP2 This is the latest update pack provided by Microsoft. Has Firewall Protection Free ~200 MB for Windows XP Home Edition Root Element XML.NET Seminar by Sid XML Structure Intro Parent Element Child Element Attribute Content Declaration

XML.NET Seminar by Sid.NET Framework Base Class Library Common Language Specification Common Language Runtime ADO.NET: Data and XML VBC++C# Visual Studio.NET ASP.NET: Web Services and Web Forms JScript… Windows Forms

XML.NET Seminar by Sid XML and ADO.NET (unified architecture) Sync DataReader SqlData- Reader OleDbData- Reader Controls, Designers, Code-gen, etc. DataSet XmlReader XmlText- Reader XmlNode- Reader XSL/T, X-Path, Validation, etc. XmlData- Document DataAdapter SqlData- Adapter OleDbData- Adapter

XML.NET Seminar by Sid XML and.NET XML: Industry standard; interoperability mechanism between applications.NET: Microsoft vision of the future of distributed applications XML is a glue that holds all.NET components together

XML.NET Seminar by Sid XML.NET and Web Services XML and.NET Client Web Service Web Service Web Service Web Service Client XML XMLXML XML XML XML HTML

XML.NET Seminar by Sid XML Parsing Models Commonly known XML parsing models : –The DOM model –Forward only push model parsing (SAX) –Forward only pull model parsing The.NET Framework XML parsing models –Forward only pull model parsing –DOM Parsing Advantages and limitations of each model

XML.NET Seminar by Sid DOM Model XML Parsing Models In memory XML parsing –A tree structure is created in memory to represent the contents of the XML document being parsed The parsing model of choice when there is a need to dynamically navigate through and manipulate (insert, update, and delete) the contents of an XML document Not a good choice when the only requirement is to parse an XML document from top to bottom in a read-only fashion Memory intensive – loading very large XML documents into the DOM can deplete system resources

XML.NET Seminar by Sid DOM Parsing XML Parsing Models Beginning XML XML Step by Step 50.00

XML.NET Seminar by Sid DOM Parsing- Accessing and Modifying Element Data XML Parsing Models Dim xmldoc As New XmlDocument() xmldoc.Load("c:\books.xml") Dim PriceNodes As XmlNodeList Dim PriceNode As XmlNode Dim Price As Double PriceNodes = xmldoc.GetElementsByTagName("Price") For Each PriceNode In PriceNodes Price = CType(PriceNode.InnerText, Double) If Price >= 50 Then Price = Price - ((5 / 100) * Price) PriceNode.InnerText = CType(Price, String) End If Next xmldoc.Save("c:\books.xml")

XML.NET Seminar by Sid Core XML.NET Namespaces System.Xml –The overall namespace for the.NET Framework classes provide standards-based support for parsing XML –Supported W3C XML standards: XML 1.0 and XML namespaces XML schemas XPath XSLT DOM level 2 core SOAP 1.1 (used in object serialization)

XML.NET Seminar by Sid Core XML.NET Namespaces System.Xml.Xsl –Contains classes that provide support for XSLT transformations System.Xml.XPath –Contains classes that provide support for executing XPath queries System.Xml.Schema –Contains classes that provide standards-based support for W3C XML schemas System.Xml.Serialization –Contains classes that are used to serialize and de-serialize.NET Framework objects to and from XML

XML.NET Seminar by Sid Dynamically generating XML in.NET Options available to programmatically generate XML: Non-cached, forward-only streaming Programming the DOM Advantages and limitations of each method

XML.NET Seminar by Sid Using XmlTextWriter Class Dynamically generating XML in.NET Implemented in the System.Xml.NET Framework namespace Inherits from the System.Xml.XmlWriter abstract class Used to programmatically generate XML in a non- cached, forward-only fashion Can be used to generate XML to a file on disk and.NET Framework Stream/TextWriter objects

XML.NET Seminar by Sid Using XmlTextWriter Class Dynamically generating XML in.NET XML Step by Step

XML.NET Seminar by Sid Dim wrt As XmlTextWriter = New XmlTextWriter("c:\books.xml", Nothing) wrt.Formatting = System.Xml.Formatting.Indented wrt.WriteStartDocument(False) wrt.WriteComment("Catalog fragment") wrt.WriteDocType("Books", Nothing, "books.dtd", Nothing) wrt.WriteStartElement("Books") wrt.WriteStartElement("Book") wrt.WriteAttributeString("", "ISBN", "", " ") wrt.WriteStartElement("Title") wrt.WriteString(“XML Step by Step") wrt.WriteEndElement() wrt.Close() Using XmlTextWriter Class

XML.NET Seminar by Sid Using DOM Dim xmldoc As New XmlDocument() Dim xmldecl As XmlDeclaration Dim xmlComment As XmlComment Dim docType As XmlDocumentType Dim xmlfragment As XmlDocumentFragment xmldecl = xmldoc.CreateXmlDeclaration("1.0", Nothing, Nothing) xmldoc.AppendChild(xmldecl) docType = xmldoc.CreateDocumentType("Books", Nothing, "c:\books.dtd", Nothing) xmldoc.AppendChild(docType) xmlComment = xmldoc.CreateComment("Catalog fragment") xmldoc.AppendChild(xmlComment) xmldoc.AppendChild(xmldoc.CreateElement("Books")) xmldoc.DocumentElement.AppendChild(GenerateBookNode(xmldoc, "XML Step by Step", " ")) xmldoc.Save("c:\books2.xml")

XML.NET Seminar by Sid Using DOM Private Function GenerateBookNode(ByVal xmldoc As XmlDocument, ByVal Title As String, ByVal ISBN As String) As XmlNode Dim BookNode As XmlNode BookNode = xmldoc.CreateElement("Book") BookNode.AppendChild(xmldoc.CreateElement("Title")) BookNode.ChildNodes(0).InnerText = Title BookNode.Attributes.Append(xmldoc.CreateAttribute("ISBN")) BookNode.Attributes.GetNamedItem("ISBN").InnerText = ISBN GenerateBookNode = BookNode End Function

XML.NET Seminar by Sid Validation of XML Validating XML in.NET Schemas help define the structure of XML documents. Validation ensures that the external data conforms to the rules (grammar) required by the schema. The three language recommendations: –Document Type Definitions (DTD) –XML Data Reduced schema (XDR) –XML Schema Definition language (XSD) XSD is the future. Schemas have several advantages over DTD: –Schemas use XML syntax and can be parsed by an XML parser. –Schemas offer data type support (integer, string, Boolean), and the ability to create other data types.

XML.NET Seminar by Sid Schemas in.NET Validating XML in.NET XML data can be validated against all the three schema languages using the.NET classes. System.Xml.XmlValidatingReader is used for validation. System.Xml.Schema is the namespace for the XML classes that provide standards-based support for XML schemas (for structures and data types). System.Xml.Schema.XmlSchemaCollection Class contains a cache of XSD and XDR schemas.

XML.NET Seminar by Sid Code Sample Public Shared Sub Main() ' Add the schema to a schemaCollection instance Dim sc As XmlSchemaCollection = New XmlSchemaCollection() sc.Add(Nothing, "schema.xsd") If (sc.Count > 0) Then ' Initialize the validating reader Dim tr As XmlTextReader = New XmlTextReader("booksSchemaFail.xml") Dim rdr As XmlValidatingReader = New XmlValidatingReader(tr) ' Set the validation type to XSD Schema rdr.ValidationType = ValidationType.Schema rdr.Schemas.Add(sc) ' Add a validation event handler and read the data AddHandler rdr.ValidationEventHandler, AddressOf ValidationCallBack While (rdr.Read()) End While End If End Sub Public Shared Sub ValidationCallBack(ByVal sender As Object, ByVal e As ValidationEventArgs) Console.WriteLine("XSD Error: {0}", e.Message) End Sub

XML.NET Seminar by Sid XSLT Transformations in.NET Applying Style-sheets to XML Documents XSL (Extensible Stylesheet Language) consists of three parts: XSLT – XSL transformations XPath – XML path language XSL-FO – XSL formatting objects XSLT is a language for transforming XML documents into text-based documents Transformation process involves three documents: Source XML document Stylesheet document Output document – XML, HTML, etc.

XML.NET Seminar by Sid XSLT in.NET Applying Style-sheets to XML Documents Implemented under System.Xml.Xsl namespace Supports W3C XSLT 1.0 recommendation Key classes: XslTransform – Transforms XML data using an XSLT stylesheet XsltArgumentList – Allows parameters and extension objects to be invoked from within the stylesheet XsltException – Returns information about the last exception thrown while processing an XSL transform

XML.NET Seminar by Sid XslTransform ‘ Transforms the XML data in the input file and outputs the result to an output file Dim xslt As XslTransform = New XslTransform() xslt.Load("books.xsl") xslt.Transform("books.xml", "output.xml") ' Transforms the XML data in the XPathDocument and outputs the result to an XmlReader Dim URL As String = " Dim xslt As XslTransform = New XslTransform() xslt.Load(URL & "books.xsl") Dim doc As XPathDocument = New XPathDocument(URL & "books.xml") Dim reader As XmlReader = xslt.Transform(doc, Nothing) ‘ Transforms the XML data in the input file and outputs the result to a stream Dim xslt As XslTransform = New XslTransform() xslt.Load("books.xsl") Dim strm As New MemoryStream() xslt.Transform(New XPathDocument("books.xml"), Nothing, strm)

XML.NET Seminar by Sid Overview of XPath XPath Queries A query language for XML – the SQL of XML Used to specify query expressions to locate nodes in an XML document Used in XSLT stylesheets to locate and apply transformations to specific nodes in an XML document Used in DOM code to locate and process specific nodes in an XML document

XML.NET Seminar by Sid XPath in.NET Related namespaces System.Xml System.Xml.XPath Key.NET Framework classes XmlDocument, XmlNodeList, and XmlNode XPathDocument XPathNavigator XPathNodeIterator XPathExpression XPath Queries

XML.NET Seminar by Sid Executing XPath Queries Using the System.Xml DOM Objects Commonly used classes: XMLDocument, XMLNodeList, XMLNode Load the XML document into the XMLDocument class Use the selectNodes/selectSingleNode method of the XmlDocument class to execute the XPath query Assign returned node list/node to an XmlNodeList/XmlNode object Use an XmlNode object to iterate through the XmlNodeList and process the results XPath Queries

XML.NET Seminar by Sid Executing XPath Queries Sample XML document: The C Programming language XML Step by Step Sample XPath query: –Select all titles that begin with the word ‘XML’ XPath Query : //Title[starts-with(.,’XML’)]

XML.NET Seminar by Sid Executing XPath Queries Dim xmlDoc as New XmlDocument Dim matchingNodes as XmlNodeList Dim matchingNode as XmlNode xmlDoc.Load “c:\books.xml” matchingNodes = xmlDoc.SelectNodes(“//Title[starts-with(.,’XML’)]”) If matchingNodes.Count = 0 Then MsgBox("No matching nodes were identified for the specified XPath query“) Else For Each matchingNode In matchingNodes MsgBox(matchingNode.Name & " : " & matchingNode.InnerText) Next End If

XML.NET Seminar by Sid Summary Introduced XML in.NET Introduced the XML parsing models in the.NET Framework Examined DOM parsing in the.NET Framework Introduced the XML related.NET Framework namespaces Examined the process of programmatically generating XML in the.NET Framework Examined the process of programmatically validating XML documents Executing XSLT transformations Executing XPath queries