讲解CO3098/CO7098、辅导Java程序设计、讲解XML Parsing、Java编程辅导

- 首页 >> Java编程

CO3098/CO7098

Coursework 1

XML Schema, XSLT and XML Parsing

Important Dates:

Handed out: 9-Oct-2018

Deadline: 29-Oct-2018 at 23:59 GMT

The deadline is strict and will not be changed. Please ensure that you submit your work in time.

This coursework counts as 10% of your final mark.

Please read guidelines on plagiarism in the study guide and course documentation.

This coursework requires knowledge about XML Schema, XSLT and DOM/SAX Parsing

Please submit a signed coversheet electronically.

Data Description

Consider an XML document (RESTController.xml):

<xml version="1.0" encoding="UTF-8"?>

<controller id="RESTController">

<package>uk.ac.le.cs.wt</package>

<extends>

<from>Remote</from>

</extends>

<import>java.rmi.Remote</import>

<import>java.rmi.RemoteException</import>

<import>java.net.*</import>

<abstract_method name="authenticateUser">

<visibility_modifier>public</visibility_modifier>

<arguments>

<parameter type="String">user</parameter>

<parameter type="String">password</parameter>

<parameter type="InetAddress">serverAddress</parameter>

</arguments>

<throws>

<exception>RemoteException</exception>

<exception>SecurityException</exception>

</throws>

<return>boolean</return>

</abstract_method>

<abstract_method name="activateUser">

<visibility_modifier>public</visibility_modifier>

<arguments>

<parameter type="URL">link</parameter>

</arguments>

<return>void</return>

</abstract_method>

</controller>

This XML document represents a Java interface below:

package uk.ac.le.cs.wt;

import java.rmi.Remote;

import java.rmi.RemoteException;

import java.net.*;

interface RESTControllerextends Remote{

public boolean authenticateUser(Stringuser,Stringpassword,InetAddressserverAddress)

throws RemoteException,SecurityException;

public void activateUser(URL link);

}

Tasks:

Task 1: [35 Marks]

Write an XML Schema (RESTController.xsd) that allows validation of the provided XML

document. Note that the schema must be consistent with these rules in Java:

An interface may extend one or many interfaces.

There can be only one package statement

There can be zero to many import statements

An interface can have zero to many abstract methods

A method only allows one value to be returned (or void)

A method can only have zero or one visibility modifier *

A method can accept zero to many arguments

Exception(s) may be thrown from a method

* If a method has no visibility modifier then it is accessible only within its own package (default

visibility); assuming all methods are non-static.

Task 2: [30 Marks]

Write an XSLT stylesheet (RESTController.xslt) that takes the provided XML document as input

and generates an HTML document as follows:

(Note: You may show the result in a different page layout or colour scheme. The page must display

the controller id, return type and the parameter list of each method)

Task 3: [35 Marks]

Write a Java program that reads the XML above and produces an output as follows. Please choose

an appropriate parsing technology (DOM/SAX).

public boolean authenticateUser(Stringuser,Stringpassword,InetAddressserverAddress)

throws RemoteException,SecurityException;

public void activateUser(URL link);

(Note: You need to implement either XMLParserDOM.java or XMLParserSAX.java)

Submission

Zip all files in a single zip file for submission.

o RESTController.xsd

o RESTController.xslt

o XMLParserDOM.java (or XMLParserSAX.java, depending on your choice)

The archive should be named CO3098_CW1_email_id.zip or CO7098_CW1_email_id.zip

(e.g. CO3098_CW1_yh37.zip).

Your submission should also include a completed coursework plagiarism coversheet (signed PDF or

image). You need to submit the zip file via Blackboard and you are allowed to re-submit as many

times as you like before the deadline. Marks for any coursework which does not have the

accompanying cover sheet will be withheld till you provide one.

Note: apart from the XML document above, we might use other XML instance documents as the

test suite for assessing task 1, 2 and 3. Your schema and the XPATH used in your XSLT should also

work for these XML documents)


站长地图