Presentation is loading. Please wait.

Presentation is loading. Please wait.

Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.

Similar presentations


Presentation on theme: "Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This."— Presentation transcript:

1 Manohar – manohar.saddala@gmail.com1 Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This is most common requirement for any business. Solution: Design a format in which the data can saved and understand further. - This requirement was first identified by IBM and came up with GML - GML is used only by IBM for internal projects SGML – Standardized General Markup Language - It is an improvement over GML - Initially released by IBM and later took by W3C SGML | |----HTML | |----XML

2 Manohar – manohar.saddala@gmail.com2 What is XML W3C - Set some standards to develop markup language. To develop a MARKUP language 1.Declare elements, attributes 2.Set grammar rules (i.e. describe how the above declared elements, attributes can be used)

3 Manohar – manohar.saddala@gmail.com3 XML W3C - Set some standards to develop markup language. To develop a MARKUP language 1.Declare elements, attributes 2.Set grammar rules (i.e. describe how the above declared elements, attributes can be used)

4 Manohar – manohar.saddala@gmail.com4 XML Standards The document must have exactly one top-level element (the document element or root element). All other elements must be nested within it. Elements must be properly nested. That is, if an element starts with another element, it must also end within that same element. Elements must have both start-tag and end-tag. The element-type name in a start-tag must exactly match in the corresponding end-tag. Element-type names are case-sensitive.

5 Manohar – manohar.saddala@gmail.com5 XSD  An XML Schema describes the structure of an XML document.  An XML Schema tells about - elements that can appear in a document - attributes that can appear in a document - which elements are child elements - the order of child elements - the number of child elements - whether an element is empty or can include text - data types for elements and attributes - default and fixed values for elements and attributes  XML Schema supports - to describe allowable document content - to validate the correctness of data - to work with data from a database - to define data facets (restrictions on data) - to define data patterns (data formats) - to convert data between different data types

6 Manohar – manohar.saddala@gmail.com Schema file can contains either 1.Simple element - Element containing only text 2.Complex element – Element containing one or more elements Note: If an element has attribute then the element is treated as complex element 1.Simple Element: - element is the root element of every XML Schema - used to define element - used to define attribute -defines the acceptable values for an element or attribute. - minimum no allowed - maximum no allowed - exact no of digits allowed - limits to set of acceptable values. - limit value to series of characters - limit the length of the value - minimum length of the value - maximum length of the value Tags used in XSD: 6

7 Manohar – manohar.saddala@gmail.com Simple Element E.g.: Cont… 7

8 Manohar – manohar.saddala@gmail.com 2.Complex Element: - used to define complex element or complex type - extending the compexType with another complexType - used of extending Cont… 8

9 Manohar – manohar.saddala@gmail.com Cont… 9

10 Manohar – manohar.saddala@gmail.com Cont… 10

11 Manohar – manohar.saddala@gmail.com Used to control how the elements are used in the document Order indicators: 1.All- Specifies that all child elements can appear in any order 2.Choice- Specifies that either one child element or another can occur 3.Sequence- Specifies that all child elements should occur in same order Occurrence indicators: 1.maxOccurs- Maximum no of times an element can occur 2.minOccurs- Minimum no of times an element can occur Indicators 11

12 Manohar – manohar.saddala@gmail.com - Enable to extend the xml document with elements not specified in schema Mixed – Allows an element to contain both elements and text XSD XML Receipt No 123456. To Manohar Date 2012-07-13. Miscellaneous 12

13 Manohar – manohar.saddala@gmail.com Namespaces 13 TargetNamespace DefaultNamespace Names with prefix Schema Import Schema Include

14 Manohar – manohar.saddala@gmail.com Is an path expression to select the nodes from XML document XPATH: 14 ExpressionDescription Nodenameselects all the nodes with the name “Nodename” /selects from the root node //selects the node from the current node and no matter where they are if the selection matches.Selects the current node..Selects parent of the current node @Selects attribute

15 Manohar – manohar.saddala@gmail.com Harry Potter 29.99 Learning XML 39.95 Path ExpressionResult bookstoreSelects all nodes with the name "bookstore“ /bookstoreSelects the root element bookstore Note: If the path starts with a slash ( / ) it always represents an absolute path to an element! bookstore/bookSelects all book elements that are children of bookstore //bookSelects all book elements no matter where they are in the document bookstore//bookSelects all book elements that are descendant of the bookstore element, no matter where they are under the bookstore element //@langSelects all attributes that are named lang XPATH: 15

16 Manohar – manohar.saddala@gmail.com Used to transform XML document into XHTML or any other XML document - Root element that declares xml document as xsl style sheet - template contains rules to apply when a specified node is matched - used to extract data from the selected node. - used to iterate the array nodes and select the node. - Conditionally selecting the node - used when you have multiple conditions using and - sort the output nodes XSLT 16


Download ppt "Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This."

Similar presentations


Ads by Google