Download presentation
Presentation is loading. Please wait.
Published byAgnes Cox Modified over 9 years ago
1
XML Anisha K J Jerrin Thomas
2
Outline Introduction Structure of an XML Page Well-formed & Valid XML Documents DTD – Elements, Attributes, Entities Parsing Strategies – DOM, SAX XML Technologies – XSL, XQuery, Etc
3
Introduction Extensible Markup Language. Used to describe data. Can define our own tags. Define data structures. Make these Structures platform independent. Process Xml defined data automatically.
4
Why do we need Xml Data-exchange Makes communication easy. Possible to define other languages.
5
Structure of an XML Page Content
6
Logical Structure The Prolog 1. XML declaration 2. Document type declaration The Document Element
7
Physical Structure The content of an XML file is contained in chunks of information called entities. 1. Internal or External 2. Parsed or Unparsed Attributes
8
Tags Should have start tag and closing tag Tags are case sensitive All tags must be nested properly Comments can be used as in HTML<!— comments Between start and empty tag there is content Empty Tag:
9
Elements and Sub-elements Example: volvo v40 green
10
Attributes Syntax:.... Example: volvo The same information can also be defined without using attributes as follows: volvo green
11
Well Formed Xml Documents Contain a root element. All other elements are children of the root element. All elements are correctly paired. The element name in a start-tag and an end-tag are exactly the same. Attribute names are used only once within the same element.
12
Valid Xml Documents The document must be well formed. The document must follow the rules defined in DTD.
13
DTD – Document Type Definition Contains rules for particular type of Xml documents. It describes the set of valid: 1. Elements 2. Attributes 3. Entities
14
Elements XML elements are declared with an element declaration. The syntax is: Category: #PCDATA, EMPTY, ANY Element content: Data or Sub-elements
15
Number of Sub-elements + one or more * zero or more ? Once or not at all | Choice
16
Attributes Syntax: E.g.:
17
Attribute type 1.CDATAThe value is character data 2.(en1|en2|..) The value must be one from an enumerated list 3.IDThe value is a unique id 4.IDREFThe value is the id of another element 5.IDREFSThe value is a list of other ids 6.NMTOKENThe value is a valid XML name 7.NMTOKENSThe value is a list of valid XML names 8.ENTITYThe value is an entity 9.ENTITIESThe value is a list of entities 10.NOTATIONThe value is a name of a notation 11.xml:The value is a predefined xml value
18
Default values 1.ValueThe default value of the attribute 2.#REQUIREDThe attribute value must be included 3.#IMPLIEDThe attribute need not be included 4.#FIXED valueThe attribute value is fixed
19
Entities Internal Entity Declaration External Entity Declaration Syntax: DTD Example: XML example: &writer;©right;
20
Internal & External DTDs Internal: External: DTD is specified after Xml declaration Public DTD: Used for broad and public usage
21
XML Parsing Strategies Simple API for Xml(SAX) Document Object Model(DOM) Xml pull parsing
22
DOM – Document Object Model The DOM represents a tree view of the XML document. A node interface model is used to access the individual elements in the node tree. XML elements can be extracted from an XML document by traversing the node tree, by accessing the elements by number, or by accessing the elements by name.
23
Node Types 1.Document type: 2.Processing inst: 3.Element: Carlsberg 4.Attribute:type="beer" 5.Text:Carlsberg
24
XML DOM Objects 1.DOM Node 2.DOM NodeList 3.DOM Document 4.DOM Element 5.DOM Attr 6.DOM Text 7.DOM CDATA 8.DOM Comment
25
XML Technologies XSL – XSLT, XSL-FO, Xpath XQuery XML Schema XForms
26
XSL - eXtensible Stylesheet Language XSL consists of three parts: XSLT is a language for transforming XML documents XPath is a language for defining parts of an XML document XSL-FO is a language for formatting XML documents
27
XQuery XQuery is a language for querying XML data XQuery is built on XPath expressions XQuery for XML is like SQL for databases
28
XML Schema The purpose of an XML Schema is to define the legal building blocks of an XML document, just like a DTD. Soon XML Schemas will be used in most Web applications as a replacement for DTDs. Here are some reasons: 1. XML Schemas are extensible to future additions 2. XML Schemas are richer and more useful than DTDs 3. XML Schemas are written in XML 4. XML Schemas support data types 5. XML Schemas support namespaces
29
XForms XForms are the next generation of HTML forms XForms are designed to handle interactive transactions XForms are platform and device independent XForms separate data and logic from presentation XForms use XML to define forms XForms contain features like calculations and validations of forms (less scripting is required)
30
Conclusion XML page with our own tags, attributes etc. DTD – Document Type Definition. Parsing – DOM, SAX >> to application layer. Display – CSS, XSL.
31
Thank You
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.