Service Computing WS 2012 Exercise 2 - IAAS

iaas.uni.stuttgart.de

Service Computing WS 2012 Exercise 2 - IAAS

Prof. Dr. Frank Leymann / Olha Danylevych

Institute of Architecture of Application Systems

University of Stuttgart

Topic: XPath / XML-Parsing / XSLT

Task 2.1 – XML-Schema

Service Computing

WS 2012

Exercise 2

Date: 10.09.12 (15:30 – 17:00, Room 38.02)

Consider the XML document available at:

http://www.iaas.unistuttgart.de/lehre/vorlesung/aktuell/vorlesungen/scomputing/uebungen/resources/exc2/articleList.xml

Develop an XML Schema for this document. How do you ensure that “USD” and

“EUR” are the only permitted currencies?

Task 2.2 – XPath-Expressions

Consider the XML document from the task 2.1.

Design the XPath expressions to realize the following queries:

Select all elements:

o that are nested on the second level of the xml document

o that have at least one attribute

o with directly nested “manufacturer” elements that contain text

starting with “C”

o whose local names contain at least one “f” and at least one “u”

o that are the last elements inside their parents

o that appear on an even position inside their parents (they appear on

position 0, 2, 4, etc.)

Select all articles:

o The price of which is 20 euro (prices in currencies other than euro

are not considered)

o The price of which is between 10 and 20 euro and they are produced

by a company whose name contains “Inc.”

Finally write an XPath query that calculates the sum of the prices of all articles

that are specified in EUR.

Note:

To try out the XPath expressions you can use some of the online tools e.g. XPath

Explorer (http://sourceforge.net/projects/xpe/) or the XPather extension for

Firefox (https://addons.mozilla.org/en-US/firefox/addon/1192/).

Task 2.3 - DOM- and SAX-Parsers

Applications use parsers to process XML document. Independently from the

particular programming language used to develop the application, developers


typically decide between the DOM- and SAX-parsers. What are the main

differences between these two types of parsers? In which cases is it better to use

a DOM parser, and when a SAX? Take in consideration, among other aspects of

the parsers, also the storage requirements, complexity of the processing and the

ease of use.

Task 2.4 – XSLT-Transformations in Java

Transform the XML document at http://www.iaas.unistuttgart.de/lehre/vorlesung/aktuell/vorlesungen/webservice1/uebungen/resources/exc2/articleList.xml

into an HTML file. The content of the XML document should be completely

included in the resulting HTML one. Write “N/A” in case if there is no information

on the availability of one of the provided articles.

The transformation must be executed using XSLT in Java. How does your Java

program look like? What is the structure of the XSLT document?

More magazines by this user
Similar magazines