Processing XML with Java
Upcoming SlideShare
Loading in...5
×
 

Processing XML with Java

on

  • 3,509 views

Processing XML with Java and JAXP - http://javaeecourse.devg.org

Processing XML with Java and JAXP - http://javaeecourse.devg.org

Statistics

Views

Total Views
3,509
Slideshare-icon Views on SlideShare
2,027
Embed Views
1,482

Actions

Likes
0
Downloads
158
Comments
1

4 Embeds 1,482

http://javaeecourse.devbg.org 1316
http://www.jornaljava.com 161
http://webcache.googleusercontent.com 4
http://static.slidesharecdn.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Good information on processing XML with Java
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ## Any changes made since the last commit will be ignored – usually rollback is used in combination with Java’s exception handling ability to recover from unpredictable errors.
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  • (c) 2007 National Academy for Software Development - http://academy.devbg.org All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##

Processing XML with Java Processing XML with Java Presentation Transcript

  • Java XML Programming Svetlin Nakov Bulgarian Association of Software Developers www.devbg.org
  • Contents
    • Introduction to XML Parsers
      • The DOM Parser
      • The SAX Parser
      • The StAX Parser
    • Introduction to JAXP
      • Using DOM
      • Using StAX
      • Java API for XPath
      • Java API for XSLT
  • XML Parsers
  • XML Parsers
    • XML parsers are programming libraries that make the work with XML easier
    • They are used for:
      • Extracting data from XML documents
      • Building XML documents
      • Validating XML documents by given scheme
  • XML Parsers – Models
    • DOM (Document Object Model)
      • Represents XML documents as a tree in the memory
      • Allows flexible and easy processing
      • Supports changing the document
    • SAX (Simple API for XML Processing)
      • Reads XML documents consequently (like a stream)
      • Allows read-only / write-only access
    • StAX (Streaming API for XML)
      • Similar to SAX but simplified
  • Using a XML Parser
    • Three basic steps to using an XML parser
      • Create a parser object
      • Pass your XML document to the parser
      • Process the results
    • Generally, writing out XML is outside scope of parsers
      • Some parsers may implement such mechanisms
  • Types of Parser
    • There are several different ways to categorize parsers:
      • Validating versus non-validating parsers
      • Parsers that support the Document Object Model (DOM)
      • Parsers that support the Simple API for XML (SAX)
      • Streaming parsers (StAX)
      • Parsers written in a particular language (Java, C#, C++, Perl, etc.)
  • The DOM Parser
  • DOM Parser Architecture
  • DOM Key Features
    • The DOM API is generally an easier API to use
      • It provides a familiar tree structure of objects
      • You can use it to manipulate the hierarchy of a XML document
    • The DOM API is ideal for interactive applications
      • The entire object model is present in memory
  • The DOM Parser – Example
    • The following XML document is given :
    <?xml version=&quot;1.0&quot;?> <library name=&quot;.NET Developer's Library&quot;> <book> <title>Programming Microsoft .NET</title> <author>Jeff Prosise</author> <isbn>0-7356-1376-1</isbn> </book> <book> <title>Microsoft .NET for Programmers</title> <author>Fergal Grimes</author> <isbn>1-930110-19-7</isbn > </book> </library>
  • The DOM Parser – Example
    • This document is represented in the in the memory as a DOM tree in the following way:
    Header part Root node
  • The SAX Parser
  • SAX Key Features
    • The Simple API for XML (SAX)
      • Event-driven
      • S erial-access mechanism
      • E lement-by-element processing
      • Do not allow going backwards or jumping ahead
      • Require many times less resources
        • Memory
        • CPU time
      • Work over streams
  • The SAX Parser
    • Working with SAX is much complex
    • Old technology
    • Use it's new equivalent – the StAX parser
  • The StAX Parser
    • Like SAX but
      • Not event driven (not callback based)
      • &quot;Pull&quot;-based
      • Developer manually say &quot;go to next element&quot; and analyze it
    • It's a new feature in Java 6.0!
  • When to Use DOM and When to Use SAX/StAX?
    • The DOM processing model is suitable when:
      • Processing small documents
      • There is a need of flexibility
      • There is a need of direct access to different nodes of the document
      • We need to change the document
    • The SAX/StAX processing model is suitable when :
      • Processing big documents
        • Big XML documents (e.g. > 20-30 MB) cannot be processed with DOM!
      • The performance is important
      • There is no need to change the document nodes
      • SAX/StAX is read-only / write-only (like the streams)
    When to Use DOM and When to Use SAX/StAX?
  • Introduction to JAXP
  • JAXP
    • J ava A PI for X ML P rocessing
    • Designed to be flexible
    • F acilitate the use of XML on the Java platform
    • P rovides a common interface for these standard APIs
      • DOM
      • SAX, StAX
      • XPath and XSL Transformations (XSLT)
  • JAXP – Plugability
    • JAXP allows you to use any XML-compliant parser
    • R egardless of which vendor's implementation is actually being used
    • P luggability layer
      • L ets you plug in an implementation of the SAX or DOM API
      • L et s you control how your XML data is displayed
  • JAXP – Independence
    • To achieve the goal of XML processor independence
      • A pplication should limit itself to the JAXP API
      • A void using implementation-dependent APIs and behavior
  • JAXP Packages
    • j avax.xml.parsers
      • The JAXP APIs
      • P rovide s a common interface for different vendors ' SAX and DOM parsers
    • org.w3c.dom
      • Defines the DOM classes
      • Document class and all the components of a DOM
  • JAXP Packages (2)
    • org.xml.sax
      • Defines the basic SAX APIs
    • javax.xml.stream
      • Define the basic StAX classes
    • javax.xml.xpath
      • Defines API for the evaluation of XPath expressions
    • javax.xml.transform
      • Defines the XSLT APIs that let you transform XML into other forms
  • Using the DOM Parser
  • DOM Document Structure Document +--- Element <dots> +--- Text &quot;this is before the first dot | and it continues on multiple lines&quot; +--- Element <dot> +--- Text &quot;&quot; +--- Element <dot> +--- Text &quot;&quot; +--- Element <flip> | +--- Text &quot;flip is on&quot; | +--- Element <dot> | +--- Text &quot;&quot; | +--- Element <dot> | +--- Text &quot;&quot; +--- Text &quot;flip is off&quot; +--- Element <dot> +--- Text &quot;&quot; +--- Element <extra> | +--- Text &quot;stuff&quot; +--- Text &quot;&quot; +--- Comment &quot;a final comment&quot; +--- Text &quot;&quot; XML input: Document structure: <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <dots> this is before the first dot and it continues on multiple lines <dot x=&quot;9&quot; y=&quot;81&quot; /> <dot x=&quot;11&quot; y=&quot;121&quot; /> <flip> flip is on <dot x=&quot;196&quot; y=&quot;14&quot; /> <dot x=&quot;169&quot; y=&quot;13&quot; /> </flip> flip is off <dot x=&quot;12&quot; y=&quot;144&quot; /> <extra>stuff</extra> <!-- a final comment --> </dots>
  • DOM Document Structure
    • There’s a text node between every pair of element nodes, even if the text is empty
    • XML comments appear in special comment nodes
    • Element attributes do not appear in tree
      • Available through Element object
  • DOM Classes Hierarchy
  • Using DOM import javax.xml.parsers.*; import org.w3c.dom.*; // G et a DocumentBuilder object DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = null; try { db = dbf.newDocumentBuilder(); } catch (ParserConfigurationException e) { e.printStackTrace(); } // I nvoke parser to get a Document Document doc = db.parse(inputStream); Document doc = db.parse(file); Document doc = db.parse(url); Here’s the basic recipe for getting started:
  • DOM Document Access Idioms // get the root of the Document tree Element root = doc.getDocumentElement(); // get nodes in subtree by tag name NodeList dots = root.getElementsByTagName(&quot;dot&quot;); // get first dot element Element firstDot = (Element) dots.item(0); // get x attribute of first dot String x = firstDot.getAttribute(&quot;x&quot;);
    • OK, say we have a Document . How do we get at the pieces of it?
    • Here are some common idioms:
  • More Document Accessors Node access methods: String getNodeName () short getNodeType () Document getOwnerDocument () boolean hasChildNodes () NodeList getChildNodes () Node getFirstChild () Node getLastChild () Node getParentNode () Node getNextSibling () Node getPreviousSibling () boolean hasAttributes () ... and more ... e.g. DOCUMENT_NODE, ELEMENT_NODE, TEXT_NODE, COMMENT_NODE, etc.
  • More Document Accessors Element extends Node and adds these access methods: String getTagName () boolean hasAttribute ( String name ) String getAttribute ( String name ) NodeList getElementsByTagName ( String name ) … and more … Document extends Node and adds these access methods: Element getDocumentElement () DocumentType getDoctype () ... plus the Element methods just mentioned ... ... and more ...
  • Writing a Document as XML
    • JAXP do not specify how to write XML document to a file
    • Most JAXP implementations have own classes for writing XML files
      • E.g. the class XMLSerializer in Apache Xerces (the standard parser in J2SE 5.0)
    import com.sun.org.apache.xml.internal. serialize.XMLSerializer; XMLSerializer xmlser = new XMLSerializer(); xmlser.setOutputByteStream(System.out); xmlser.serialize(doc);
  • Reading and Parsing XML Documents with the DOM Parser Live Demo
  • Creating & Manipulating DOM Documents // Get new empty Document from DocumentBuilder Document doc = docBuilder.newDocument(); // Create a new <dots> element // and add it to the document as root Element root = doc.createElement(&quot;dots&quot;); doc.appendChild(root); // Create a new <dot> element // and add as child of the root Element dot = doc.createElement(&quot;dot&quot;); dot.setAttribute(&quot;x&quot;, &quot;9&quot;); dot.setAttribute(&quot;y&quot;, &quot;81&quot;); root.appendChild(dot);
    • The DOM API also includes lots of methods for creating and manipulating Document objects:
  • More Document Manipulators Node manipulation methods: void setNodeValue ( String nodeValue ) Node appendChild ( Node newChild ) Node insertBefore ( Node newChild , Node refChild ) Node removeChild ( Node oldChild ) ... and more ... Element manipulation methods: void setAttribute ( String name , String value ) void removeAttribute ( String name ) … and more … Document manipulation methods: Text createTextNode ( String data ) Comment createCommentNode ( String data ) ... and more ...
  • Building Documents with the DOM Parser Live Demo
  • Using The StAX Parser
  • The StAX Parser in Java
    • As from Java 6 the StAX parser is available as part of Java
    • Two basic StAX classes
      • XMLStreamReader
        • Pull based XML streaming API for parsing XML documents – read-only
      • XMLStreamWriter
        • Streaming based builder for XML documents – write-only
  • Parsing Documents with the StAX Parser – Example FileReader fileReader = new FileReader(&quot;Student.xml&quot;); XMLInputFactory factory = XMLInputFactory. newInstance (); XMLStreamReader reader = factory.createXMLStreamReader(fileReader); String element = &quot;&quot;; while (reader.hasNext()) { if (reader.isStartElement()) { element = reader.getLocalName(); } else if (reader.isCharacters() && !reader.isWhiteSpace()) { System. out .printf(&quot;%s - %s%n&quot;, element, reader.getText()); } reader.next(); } reader.close()
  • Parsing Documents with the StAX Parser Live Demo
  • Creating Documents with the StAX Parser – Example String fileName = &quot;Customers.xml&quot;; FileWriter fileWriter = new FileWriter(fileName); XMLOutputFactory factory = XMLOutputFactory. newInstance (); XMLStreamWriter writer = factory.createXMLStreamWriter(fileWriter); writer.writeStartDocument(); writer.writeStartElement(&quot;Customers&quot;); writer.writeStartElement(&quot;Customer&quot;); writer.writeStartElement(&quot;Name&quot;); writer.writeCharacters(&quot;ABC Pizza&quot;); writer.writeEndElement(); writer.writeStartElement(&quot;Address&quot;); writer.writeCharacters(&quot;1 Main Street&quot;); writer.writeEndElement(); writer.writeEndElement(); writer.writeEndElement(); writer.writeEndDocument(); writer.flush();
  • Parsing Documents with the StAX Parser Live Demo
  • Using XPath in Java Searching nodes in XML documents
  • Parsing XML Documents with XPath
    • To evaluate an XPath expression in Java, create an XPath object
    • Then call the evaluate method
      • expression is an XPath expression
      • doc is the Document object that represents the XML document
    XPathFactory xpfactory = XPathFactory.newInstance(); XPath x path = xpfactory.newXPath(); String result = x path.evaluate(expression, doc)
  • Sample XML Document
    • <?xml version=&quot;1.0&quot; encoding=&quot;windows-1251&quot;?>
    • <items culture=&quot;en-US&quot;>
    • <item type=&quot;beer&quot;>
    • <name>Zagorka</name>
    • <price>0.54</price>
    • </item>
    • <item type=&quot;food&quot;>
    • <name>kepab</name>
    • <price>0.48</price>
    • </item>
    • <item type=&quot;beer&quot;>
    • <name>Amstel</name>
    • <price>0.56</price>
    • </item>
    • </items>
  • Parsing with XPath – Example
    • For example, obtains as result the string &quot; 0.48 “
    • XPath can also match multiple nodes and return NodeList :
    String result = xpath.evaluate(&quot;/items/item[2]/price&quot;, doc) NodeList nodes = (NodeList) xpath.evaluate( &quot;/items/item[@type='beer']/price&quot;, doc, XPathConstants.NODESET); for (int i=0; i<beerPriceNodes.getLength(); i++) { Node priceNode = nodes.item(i); System.out.println(node.getTextContent()); }
  • Using XPath Live Demo
  • Modifying XML with DOM and XPath Live Demo
  • XSL Transformations in JAXP javax.xml.transform.Transformer
  • XSLT API
  • Transforming with XSLT in Java with JAXP
    • The JAXP uses a factory design pattern
      • This hides the implementation classes
    • The procedure for XSL transforming is:
      • Create a TransformerFactory instance
      • Load your stylesheet into a Transformer instance
      • Transform your source to your output using the Transfomer instance
  • Transforming with XSLT in Java with JAXP (2)
    • Establish the factory and environment
    • Load and compile the XSL stylesheet
    • Apply the stylesheet over given document
    TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer xslTransformer = tFactory.newTransformer( new StreamSource(&quot;style sheet .xsl&quot;)); xslTransformer.transform( new StreamSource(&quot;in put .xml&quot;), new Stream Result (&quot;out put .xml&quot;));
  • Transforming with XSL – Example <?xml version=&quot;1.0&quot;?> <library name=&quot;.NET Developer's Library&quot;> <book> <title>Programming Microsoft .NET</title> <author>Jeff Prosise</author> <isbn>0-7356-1376-1</isbn> </book> <book> <title>Microsoft .NET for Programmers</title> <author>Fergal Grimes</author> <isbn>1-930110-19-7</isbn> </book> </library> library.xml
  • Transforming with XSL – Example (2) <?xml version=&quot;1.0&quot; encoding=&quot;windows-1251&quot;?> <xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;> <xsl:output method=&quot;xml&quot; encoding=&quot;utf-8&quot; indent=&quot;yes&quot; omit-xml-declaration=&quot;yes&quot;/> <xsl:template match=&quot;/&quot;> <html> <head> <meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset= utf-8 &quot; /> </head> <body> <h1>Моята библиотека</h1> <table bgcolor=&quot;#E0E0E0&quot; cellspacing=&quot;1&quot;> (example continues) library-xml2html.xsl
  • Transforming with XSL – Example (3) <tr bgcolor=&quot;#EEEEEE&quot;> <td><b>Заглавие</b></td> <td><b>Автор</b></td> </tr> <xsl:for-each select=&quot;/library/book&quot;> <tr bgcolor=&quot;white&quot;> <td><xsl:value-of select=&quot;title&quot;/></td> <td><xsl:value-of select=&quot;author&quot;/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> library-xml2html.xsl
  • Transforming with XSL – Example (4) public class XSLTransformDemo { public static void main(String[] args) throws TransformerException { TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer xslTransformer = tFactory.newTransformer( new StreamSource(&quot;library-xml2html.xsl&quot;)); xslTransformer.transform( new StreamSource(&quot; library .xml&quot;), new StreamResult(&quot; library . ht ml&quot;)); } } XSLTransformDemo.java
  • Transforming with XSL – Example (5) <html> <head> <meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;/> </head> <body> <h1>Моята библиотека</h1> <table bgcolor=&quot;#E0E0E0&quot; cellspacing=&quot;1&quot;> <tr bgcolor=&quot;#EEEEEE&quot;> <td><b>Заглавие</b></td> <td><b>Автор</b></td> </tr> (example continues) Result : library.html
  • Transforming with XSL – Example (6) <tr bgcolor=&quot;white&quot;> <td>Programming Microsoft .NET</td> <td>Jeff Prosise</td> </tr> <tr bgcolor=&quot;white&quot;> <td>Microsoft .NET for Programmers</td> <td>Fergal Grimes</td> </tr> </table> </body> </html> Result : library.html
  • XSL Transformations Live Demo
  • Exercises
    • Write a program that extracts from the file &quot; students.xml &quot; all available information about the students from 3-rd course (name, exams, etc.). Use the DOM parser.
    • Write a program that appends a new student &quot;Peter Petrov&quot; to the file students.xml and produces a new XML file as a result.
    • Write a program that appends a new exam to given student. The students and their exams are taken from the file students.xml and the results should be stored in a new XML file newStudents.xml .
  • Exercises (2)
    • Write a program that extracts from the file &quot; students.xml &quot; all available information about the students from 3-rd course (name, exams, etc.). Use XPath.
    • Write a program that changes all grades for the student &quot;Peter Petrov&quot; to &quot;6&quot;. Produce a new XML file as a result. Use StAX parser.
    • Write a program that builds an XML file catalog.xml containing a catalog of books (author, title, isbn, pages). Use StAX parser.
  • Exercises (3)
    • Using the StAX parser write a program that extracts all books' names from the file catalog .xml .
    • Using the StAX parser write a program that extracts from the students.xml all students' names. Process only students with more than one excellent grade.
    • Write an XML file containing orders. Each order is described by date, customer name and a list of order items. Each order item consists of product name, amount and price.
    • Write an XSL stylesheet to transform the XML file to a human readable XHTML document. Sort the products in alphabetical order.
  • Exercises (4)
    • Write a JAXP based Java program to apply the XSL stylesheet over the XML document.
    • Test the produced XHTML file in your Web browser.
    • Write your CV in XML format. It should have the following structure:
      • Personal information (name, DOB, ...)
      • Education
      • Skills
      • Work experience
      • ...
  • Exercises (5)
    • Write a XSL stylesheet for transforming the CV to HTML and XML with other structure. Write a program to apply the stylesheet.