Suppose that you write your own HTTP server in Java
Name June 2013 Adelaide
Due: Tuesday, June 18, 11:59:00 PM
This is a low percentage take home exam that will prepare you for the final exam. Please take it seriously. It is fine to test your answers with Xalan or with an online tool. Be prepared to answer similar questions without such aides on the Final Exam.
Each question is worth four points. In your answers to the XSLT questions, be sure to show the exact output with tags as well as text. It is not enough to show how an answer might appear in a browser. You must show all tags. For multiple choice questions, give the best single answer.
Consider the following XML document (Books.xml):
Black Water
Joyce Carol Oates
E P Dutton
Radical Acceptance
Tara Brach
Random House
NYC
The Road
Cormac McCarthy
Alfred Knopf
1) What would be the output if the XML file (Books.xml) were processed by Xalan along with the following XSLT program?
2) What would be the output if the XML file (Books.xml) were processed by Xalan along with the following XSLT program?
3) What would be the output if the XML file (Books.xml) were processed by Xalan along with the following XSLT program?
4) What would be the output if the XML file (Books.xml) were processed by Xalan along with the following XSLT program?
5) What would be the output if the XML file (Books.xml) were processed by Xalan along with the following XSLT program?
3:
2:
1:
6) What would be the output if the XML file (Books.xml) were processed by Xalan along with the following XSLT program?
7) What would be the output if the XML file (Books.xml) were processed by Xalan along with the following XSLT program?
Book
Author
8) What would be the output if the XML file (Books.xml) were processed by Xalan along with the following XSLT program?
JSON (
)
[
{},
{}
]
9) What would be the output if the XML file (Books.xml) were processed by Xalan along with the following XSLT program?
Root
10) What would be the output if the XML file (Books.xml) were processed by Xalan along with the following XSLT program?
Consider the code we studied from the article on Ajax.
public void doPost(HttpServletRequest req,
HttpServletResponse res)
throws java.io.IOException {
Cart cart = getCartFromSession(req);
String action = req.getParameter("action");
String item = req.getParameter("item");
if ((action != null)&&(item != null)) {
// Add or remove items from the Cart
if ("add".equals(action)) {
cart.addItem(item);
} else if ("remove".equals(action)) {
cart.removeItems(item);
}
}
// Serialize the Cart's state to XML
String cartXml = cart.toXml();
// Write XML to response.
res.setContentType("application/xml");
res.getWriter().write(cartXml);
}
(11) Circle the one correct statement:
a. this code is responding to a SOAP request with a SOAP document.
b. this code executed on the initial request to the web application.
c. this code executed within the browser.
d. this code is Javascript.
e. this code is responding to an HTTP request with XML over HTTP.
(12) Circle the one correct statement:
a. The asynchronous call received HTML from the server.
b. The update to the HTML was based on the XML received.
c. The update to the XML was based on the HTML received.
d. Javascript ran on the server.
e. JSP code ran in the browser.
(13) Consider the following code from the Ajax article:
Add to Cart
The method “addToCart()
a. is a callback method.
b. is an event handler.
c. creates an XMLHttpRequest object and assigns to it a callback method.
d. returns control to the browser thread only after the server responds.
e. Both b and c are correct.
(14) Consider the following code from the article on Ajax.
function getReadyStateHandler(req, responseXmlHandler) {
return function () {
if (req.readyState == 4) {
if (req.status == 200) {
responseXmlHandler(req.responseXML);
} else
{
alert("HTTP error: "+req.status);
}
}
}
Which of the following code segments makes the most sense?
a. req.readyState = 4;
req.readyStatus = 100;
updateCart(req).getReadyStaeHandler();
b. var x = getReadyStaeHandler.function();
c. var req = newXMLHttpRequest(new getReadyStateHandler());
var handler = req.function();
d. var req = newXMLHttpRequest();
var handlerFunction = getReadyStateHandler(req, updateCart);
req.onreadystatechange = handlerFunction;
e. updateCart = newXMLHttpReques().
updateCart.getReadyStateHandler();
(15) In homework 1, you were asked to create a grammar in XSDL. Create a grammar for Books.xml shown at the top of this exam:
(16) Part a) asks you to state one reason why JSON might be preferred to XML. Part b) asks you to state one reason why XML might be preferred to JSON. Part c) asks you a general question about the two.
a) JSON is preferable to XML because: JSON results in shorter messages
b) XML is preferable to JSON because: XML has industry standard languages
c) Languages such as XBRL, FpML and MathML are encoded how? (Circle XML or JSON).
(17) Suppose we have a line of XML that reads Jones.
a. id is considered an element.
b. id is considered a namespace.
c. id is considered an attribute.
d. id is considered a property.
e. id is considered a namespace prefix.
(18) JSON is
a. an XML language
b. used to describe arbitrary Java objects
c. used to describe Javascript objects
d. a non-readable binary format
e. an obvious replacement for XML
(19) Write an XML document that corresponds to the following JSON message. Namespaces are not required.
{
"firstName": "John", "lastName": "Smith",
"address":
{ "streetAddress": "21 2nd Street",
"city": "New York", "state": "NY",
"postalCode": "10021"
},
"phoneNumbers":
[ { "type": "home", "number": "212 555-1234" },
{ "type": "fax", "number": "646 555-4567" } ]
}
(20) Briefly describe what will occur when the following HTML file is downloaded to a browser. That is, describe what the browser will do. Be as specific as possible.
function loadXMLDoc(dname) {
if (window.XMLHttpRequest) {
xhttp=new XMLHttpRequest();
}
else {
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",dname,false);
xhttp.send("");
return xhttp.responseXML;
}
function displayResult(){
xml=loadXMLDoc("cdcatalog.xml");
xsl=loadXMLDoc("cdcatalog.xsl");
if (window.ActiveXObject) {
ex=xml.transformNode(xsl);
document.getElementById("example").innerHTML=ex;
}
else if (document.implementation && document.implementation.createDocument) {
xsltProcessor=new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
resultDocument = xsltProcessor.transformToFragment(xml,document);
document.getElementById("example").appendChild(resultDocument);
}
}
(21) Draw a picture and describe what the following XPATH expression does.
//coolTag[anotherTag="6502"]/anotherElement
(22) The following lines of code would likely be found where?
a) In a Java application.
b) In a JavaScript routine.
c) In a servlet.
d) In a JSP page.
e) As part of an AJAX request message.
(23) Briefly describe the contents of a typical Atom or RSS document.
Atom and RSS are XML languages used to allow readers to map titles and descriptions to source of content via links. A typical Atom or RSS document would contain many triples of title, description and link elements.
(24) The XSLT language is able to process XML documents containing namespaces. (Circle True or False).
(25) Consider the following code snippet from Wikipedia:
XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(...);
while (xmlStreamReader.hasNext()) {
xmlStreamReader.next();
}
a. This programmer is using Stax. Briefly describe a program that uses DOM rather than Stax.
That is, describe how a programmer interacts with the XML. What abstraction is provided
by the parser? You should be able to look around for some example programs that utilize DOM
in Java to process XML. Describe what the code looks like.
b. Again, this programmer is using Stax. Briefly describe a program that uses SAX rather than Stax.
That is, describe how a programmer interacts with the XML. What abstraction is provided
by the parser? You should be able to look around for some example programs that utilize SAX
in Java to process XML. Describe what the code looks like.
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- write your own will
- write in your own words generator
- how to write your own song
- write your own song online
- how to write your own will
- write your own story
- write your own name worksheets
- write your own business plan
- write your own song lyrics
- how to write your own music
- write your own lyrics online
- write your own will template