CO3102/CO7102 Mobile and Web Applications Coursework 1
Web Data Interchange formats - XML and JSON Important Dates:
Handed out: 3-Oct-2023 BST Deadline: 7-Nov-2023 at 16:59 GMT
Please ensure that you submit your work on time.
-
This coursework counts as 15% of your final mark.
-
Please read the guidelines on plagiarism in the study guide and course documentation.
-
This coursework requires knowledge of XML Schema, XSLT, JSON and Document Pars-
ing.
-
Learning outcome:
◦ Use data-interchange formats (XML and JSON) and techniques appropriately to create documents and handle data.
Data Description
Consider an XML document (WebServiceInterface.xml):
<?xml version="1.0" encoding="UTF-8"?> <ServiceInterface name="IAuthService">
<class>Remote</class> </superclass>
<include>java.rmi.Remote</include> <include>java.rmi.RemoteException</include> <include>java.io.*</include> <abstract_method id="authenticateUser">
<access>public</access> <parameterList>
<parameter type="String">account</parameter>
<parameter type="String">password</parameter>
</parameterList>
<exceptions>
<throws>IOException</throws>
<throws>RemoteException</throws> </exceptions> <return>boolean</return>
</abstract_method> <abstract_method id="showMessage">
<access>public</access> <parameterList>
<parameter type="String">message</parameter>
</parameterList>
<return>void</return>
</abstract_method> </ServiceInterface>
This XML document describes a Java interface below:
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.io.*;
interface IAuthService extends Remote{
public boolean authenticateUser(String account, String password) throws IOException, RemoteException;
private void showMessage (String message); }
Tasks:
Task 1: [40 Marks]
Write an XML Schema (WebServiceInterface.xsd) to validate the provided XML document. Note that the schema defined must adhere to the following Java rules:
-
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
* Note: If a method does not explicitly have a visibility modifier (e.g., “public”), it is accessible only within its own package (default visibility). This assume all methods are non-static. If the package statement is omitted, the class belongs to the “default” package.
(Hint: refer to lab exercise – Week 1) Task 2: [30 Marks]
Write an XSLT stylesheet (ServiceInterface.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. (Hint: Lab Week 2/3)
Task 3: [30 Marks]
Write a program that extracts some information from the XML above and generates the JSON output as follows. Please choose an appropriate parsing technology.
{
"abstract_method": [{
"method_name": "authenticateUser", "visibility": "public", "arguments": {
"parameter": [{
"datatype": "String",
"label": "account"
},
{
"datatype": "String",
"label": "password"
} ]
},
"exceptions": {
"exception": [
"IOException",
"RemoteException" ]
},
"return": "boolean" },
{
"method_name": "showMessage",
"visibility": "public",
"arguments": {
"parameter": [{ "datatype": "String",
"label": "message"
}]
},
"return": "void"
}
] }
For Task 3, a Java template (WebServiceInterfaceParser.java) is provided, and you'll require xer- cesImpl.jar available on Blackboard. However, you can opt for alternative programming languages (e.g., Python, C++, C#, JavaScript, etc.) and parsers for this task. In such cases, please provide a README.txt file detailing the execution steps for your code.
It's important to note that the intentional formatting of the JSON output aims to prevent the use of pre-built XML to JSON functions from specific APIs. While you're free to choose parsers, the pars- ing technique's implementation must be in your code. For example, the program should generate the specified JSON output without including elements like "package," "import," etc. Furthermore, use of any built-in XML-to-JSON libraries for XML to JSON transformation (such as "toJSONObject" in Python etc), is not permitted.
Submission
-
Zip all files in a single zip file for submission.
o WebServiceInterface.xsd
o WebServiceInterface.xslt
o WebServiceInterface.java (or in your language of choice) -
The archive should be named CO3102_CW1_email_id.zip or CO7102_CW1_email_id.zip (e.g. CO3102_CW1_yh37.zip).
Your submission should also include a completed coursework plagiarism coversheet (print and 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.
Marking Scheme
Note: In addition to the sample XML provided, additional XML documents will be included in thetest suite.
Part 1: XML Schema validity checking will be automated. In total, a test suite consisting of 12 XML documents will be used for the assessment. The marks will be distributed according to test results.
Part 2: XSLT will be compiled and applied to 7 test cases (XML documents) for the assessment. All HTML pages will be checked by TA(s) manually. The marks will be distributed according to test results.
Part 3: In total, 7 test cases (XML documents) will be used the assessment. Any JSON generated by your XML Parser will be checked by an JSON validator. The marks will be distributed accord- ing to test results.
Anonymous marking
We operate an anonymous marking scheme. All submitted files will be renamed using anonymous fingerprinting generated by SHA256.