Download presentation
Presentation is loading. Please wait.
1
XML: The new standard -Eric Taylor
2
Overview What is XML? Why use XML? Details of the language
Incorporating XML Business Application Small Assignment
3
What is XML? eXtensible Markup Language Markup language like HTML
Designed to carry data, not display it W3C recommended World Wide Web Consortium
4
What is XML? Plain text. What does it do? Not an independent language.
The Design: Compatibility Straightforward Fast Wide support
5
Why use XML? Simplifies HTML changes based on data changes.
Standardized data sharing. Too many possibilities without it. Incompatible applications not affected. Hardware/Software independent Minor exceptions
6
Language Details Tag based. Unlike HTML, all tags are user-defined.
<random_tag_name> data_to_be_stored </random_tag_name> Data stored between tags, or within tags as attributes. Attributes are normally used for information that describes the tag itself, not necessarily the information you want to store. Ex: <book internal_id=“11421” />
7
Language Details Tree structure <library>
<book internal_id=“11421”> <name> A Game of Thrones </name> <isbn> </isbn> … </book> <book internal_id=“11422”> <name> A Clash of Kings </name> <isbn> </isbn> </library>
8
Language Details
9
Language Details Example 2: From w3schools.com
10
Language Details Syntax Details: Case sensitive tags. Defined values
Quoted values Nesting: bold, italic, etc… Naming rules
11
Language Details Namespaces: Think of <include> statements.
Allows reference to different types of data with similar names. Allows reference to custom data-types. Integer, decimal, string fields, etc, with restrictions and/or patterns.
12
Language Details <root>
<h:table xmlns:h=" <h:tr> <h:td>Apples</h:td> <h:td>Bananas</h:td> </h:tr> </h:table> <f:table xmlns:f=" <f:name>African Coffee Table</f:name> <f:width>80</f:width> <f:length>120</f:length> </f:table> </root>
13
Language Details Validation:
How do we know an XML document is correct? How do we know we are getting the information we want? “Well formed” Adheres to syntax rules Easily done with XML software and processing code. Validity: Answers the “are we getting what we want?” question. Follows the given XML schema (known as an XSD).
14
Language Details What is a schema (XSD)?
XML file with the extension .xsd Dictates the allowed structure of a corresponding XML file. Defines possible fields, field values, etc. Used in process of ‘Schema Validations’. Pass or fail check if the corresponding XML file contains the appropriate information. Structure and data types, NOT content (elements vs. their value).
15
Language Details XML File: <note> <to>Tove</to>
<from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> XSD File: <xs:element name="note"> <xs:complexType> <xs:sequence> <xs:element name="to" type="xs:string"/> <xs:element name="from" type="xs:string"/> <xs:element name="heading" type="xs:string"/> <xs:element name="body" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element>
16
Incorporating XML Parsing XML to use it: DOM (Document Object Model).
Standard way for accessing and manipulating XML documents. xmlDoc - the XML document created by the parser. getElementsByTagName(“tag_name")[0] - the first <tag_name> element childNodes[0] - the first child of the <tag_name> element (the text node) nodeValue - the value of the node (the text itself) some_variable=xmlDoc.getElementsByTagName(“book”)[0].childNodes[0].nodeValue;
17
Incorporating XML Parsing commonly done via JavaScript in web applications. Java can import libraries to use the standard DOM for parsing.
18
Incorporating XML From w3schools.com
19
Incorporating XML XSLT used to display and format XML.
Basically “transforming XML to HTML before it is displayed by the browser”.
20
XML in Practice Allows for extension to legacy systems.
Create a new ‘front end’ process to make the data match to legacy. Things to consider: Use similar XML software to eliminate small differences. Establish a common schema Schema validations on both ends of transmission. Business logic to process the data.
21
Small Assignment: Download the 30 day free trial of XML Spy. (very quick installation) Go through the ‘getting started’ tutorial. Create a sample schema based on some of the previous examples. Create an XML document based on the schema, and validate. Load the XML file into an HTML document and display the values. Use Tomcat, or any IDE with a preview function.
22
References http://www.tizag.com/xmlTutorial/ www.w3schools.com
Amiano, Mitch, Conrad D'cruz, Kay Ethier, and Michael D. Thomas. XML Problem-Design-Solution. Indianapolis: Wiley Inc, 2006.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.