Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2012 Accenture All Rights Reserved.Copyright © 2012 Accenture All Rights Reserved. Accenture, its logo, and High Performance Delivered are.

Similar presentations


Presentation on theme: "Copyright © 2012 Accenture All Rights Reserved.Copyright © 2012 Accenture All Rights Reserved. Accenture, its logo, and High Performance Delivered are."— Presentation transcript:

1 Copyright © 2012 Accenture All Rights Reserved.Copyright © 2012 Accenture All Rights Reserved. Accenture, its logo, and High Performance Delivered are trademarks of Accenture. Application Delivery Fundamentals 2.0: Java Module 24: Web-Based Programming XML and XSLT

2 Copyright © 2012 Accenture All Rights Reserved. Module Objectives Describe XML features and purpose. Explain the rules for well-formed XML. Identify the key features of the XML Schema. Explain XML Validation. Explain XML Transformation (XML and XSLT). At the end of this module, you will be able to: 2

3 Copyright © 2012 Accenture All Rights Reserved. Agenda This module covers the following topics: XML Overview and Characteristics XML Purpose XML Self-Describing Syntax XML Sample Areas of Application Well-Formed XML XML Transformation Summary 3

4 Copyright © 2012 Accenture All Rights Reserved. XML Overview (1 of 2) 4 eXtensible Markup Language (XML) is a common tool for data transmission between a variety of web applications and thus simplifies data sharing. XML standardises and simplifies a way of encoding both text and data that can be exchanged across a diverse range of hardware, operating systems, and applications.

5 Copyright © 2012 Accenture All Rights Reserved. XML Overview (2 of 2) 5 It is similar enough to HTML so those who are familiar with HTML can pick up basic XML knowledge. However, XML is not a replacement for HTML. In most web applications, XML is used to transport data, while HTML is used to format and display the data.

6 Copyright © 2012 Accenture All Rights Reserved. Simple A text file Extensible Heavily used Platform independent A gateway for communication Based on international standards Allows validation using schema languages XML XML Characteristics 6

7 Copyright © 2012 Accenture All Rights Reserved. XML User-defined tags Serves as a base/standard for other languages Used to store and exchange data Reuse of data Transmit data to any device XML Purpose 7

8 Copyright © 2012 Accenture All Rights Reserved. XML A Self-Describing Syntax (1 of 3) 8 XML tags can be defined to describe the data in a file allowing users to describe the structure and nature of the data. In essence, the file becomes self-describing and there are three key advantages to this. 1. Users can locate information easily within a file. James S. Hubert 618 West Blvd. Houston TX 76847 USA Hubert USA

9 Copyright © 2012 Accenture All Rights Reserved. XML A Self-Describing Syntax (2 of 3) 9 2. The file provides sufficient information for the software to determine how to read the data. James S. Hubert 618 West Blvd. Houston TX 76847 USA 76847 In this example the software has determined that is a numeric data value.

10 Copyright © 2012 Accenture All Rights Reserved. XML A Self-Describing Syntax (3 of 3) 10 3. The location of information is not dependent on where it occurs within the file, but where the tags occur within the file. This means that it is much easier to modify the data structure. Despite the two lines being reversed the task of retrieving the information would be exactly the same. This can be a huge advantage if larger modifications need to be made to a data set, such as adding a new set of variables.. Houston TX 76847 USA.. Houston 76847 TX USA..

11 Copyright © 2012 Accenture All Rights Reserved. XML Used for database design Commonly used for data interchange Used for configuration Documents can be transformed Used for internal documentation XML Sample Areas of Application 11

12 Copyright © 2012 Accenture All Rights Reserved. XML Well-Formed XML A well-formed XML document has to follow several generic rules, such as: XML declaration One root element Proper nesting Elements must obey the XML naming convention Every start tag must have a matching end tag Proper attributes and comments 12

13 Copyright © 2012 Accenture All Rights Reserved. XML Well Formed XML: Example (1 of 3) Every start tag must have a matching end tag Proper attributes and comments NewCodington NewCodington NewCodington NewCodington 13

14 Copyright © 2012 Accenture All Rights Reserved. XML Well Formed XML: Example (2 of 3) XML declaration Provides the version of XML in use It could also specify the character encoding used One root element...... 14

15 Copyright © 2012 Accenture All Rights Reserved. XML Well Formed XML: Example (3 of 3) Proper nesting Elements must obey the XML naming convention NewCodington NewCodington Dalmatian Dog Dalmatian Dog 15

16 Copyright © 2012 Accenture All Rights Reserved. Well Formed XML: See It 16 Demonstration: Faculty will demonstrate how to fix errors in XML code to create well-formed XML code. Time Allocated: 10 minutes Environment or File: ZooDemo.xml Steps: 1.Open the project Week1n2Codebase_participant in Eclipse 2.Go to the src folder 3.Go to com.accenture.adf.newcodington.module24.sample 4.Open the ZooDemo.xml file. 5.Locate and fix the XML code errors for the following: Tags, Attributes, Declarations, Naming conventions, Root elements, Nesting

17 Copyright © 2012 Accenture All Rights Reserved. Well Formed XML: Try It Now You Try It: Fix the errors in the XML code to create well- formed XML code. 17 Time Allocated: 15 minutes Environment or File: EventsTryIt.xml Steps: 1.Open the project Week1n2Codebase_participant in Eclipse 2.Go to the src folder 3.Go to com.accenture.adf.newcodington.module24.sample 4.Open the EventsTryIt.xml file. 5.Locate and fix the XML code errors for the following: Tags, Attributes, Declarations, Naming conventions, Root elements, Nesting

18 Copyright © 2012 Accenture All Rights Reserved. Well Formed XML: Solution (1 of 2) Your faculty will now provide you with the Solution to check and update your file. The XML code extract should look something like this:. 9 Adults and Kids 900 to 1800 3 P002 ChristmasEveBall Ball for Singles 3 Adults and Kids 1700 to 2000 15 P003 18

19 Copyright © 2012 Accenture All Rights Reserved. Well Formed XML: Solution (2 of 2) The XML code extract should look something like this: Klenz for Kids Painting and singing for Kids 6 Kids 1000 to 1600 5 P001.. 19

20 Copyright © 2012 Accenture All Rights Reserved. XML Transformation Overview XSLT Processor Source Document (XML) Output Document (XML, HTML,..) XSL Style Sheet 20

21 Copyright © 2012 Accenture All Rights Reserved. XML Transformation Purpose XML transformation: Performs styling operations on XML data. Performs advanced data processing on XML data. Creates content that can be used for various purposes. 21

22 Copyright © 2012 Accenture All Rights Reserved. XML Transformation Sample Areas of Application (SAA) XSLT style sheets can take the same data present in an XML file and do the following: Display them in a traditional or mobile browser. Return them as the response for a Web service. 22

23 Copyright © 2012 Accenture All Rights Reserved. XML Transformation SAA Example: XSL File (1 of 2) 23 This is an example of an.xsl file: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> My Animal Collection Animal Quantity

24 Copyright © 2012 Accenture All Rights Reserved. XML Transformation SAA Example: XSL File (2 of 2) 24.xsl file continued:

25 Copyright © 2012 Accenture All Rights Reserved. XML Transformation SAA Example: XML File 25 This is an example of an.xml file: Monkey 20 Elephant 6 Tiger 3 This statement links the XML document to the XSL style sheet

26 Copyright © 2012 Accenture All Rights Reserved. Questions and Comments 26

27 Copyright © 2012 Accenture All Rights Reserved. Module Summary XML is used for transmitting data to any device, is independent of language, is self-describing, and can be edited using a standard text editor. Elements in a well-formed XML document must follow generic rules. Valid XML should not contain any tags that are not permitted by the schema. XML Transformation (XSLT) is designed to transform an input XML document into an output XML document to satisfy a specific goal. 27 The key points from this module are:


Download ppt "Copyright © 2012 Accenture All Rights Reserved.Copyright © 2012 Accenture All Rights Reserved. Accenture, its logo, and High Performance Delivered are."

Similar presentations


Ads by Google