95-733 Internet Technologies Mini 5 M14 Homework 2 Due Date : Thursday, June 19, 11:59 PM 2014 Lab Topics: XML, the Extensible Style Sheet Language for Transformations XSLT, Atom, and RSS The actual homework begins at Part 6. Parts 1 - 5 are for instruction only. It is strongly recommended that you work through parts 1 - 5. In this lab we will be programming in a transformation language called XSLT. XSLT is used to transform one XML document into another XML document (with a different structure). In order to write programs in XSLT, we need an XML parser (XSLT programs are XML documents) and an XSLT interpreter. The parser is called "Xerces". The interpreter is called "Xalan" (Xalan uses Xerces). The required jar files for XSLT processing using Xalan are : xalan.jar, xercesImpl.jar, xml-apis.jar and xsltc.jar and serializer.jar. These may be downloaded from the Apache Foundation. Part 1 Command Line XSLT ======================== For DOS based machines, create a directory called "bats" and place a batch file called "xalan.bat" in that directory. Place the path to your bats directory in the system path variable. I recommend that you actually type the xalan.bat file into a text editor. The copy and paste approach has been troublesome. The file xalan.bat will hold the following: java org.apache.xalan.xslt.Process -IN %1 -XSL %2 -OUT %3 This java command will run the code in the Process class. You will need to have the jar files mentioned above on your classpath before running xalan.bat. For Unix based machines, you will use a script file called xalan with execute permissions. My xalan jar files are saved in /Users/mm6/Applications/xalan. My xalan script is shown below. #!/bin/sh export XALAN_HOME=/Users/mm6/Applications/xalan export CP=$XALAN_HOME/xalan.jar:$XALAN_HOME/xercesImpl.jar:$XALAN_HOME/xml- apis.jar:$XALAN_HOME/xsltc.jar:$XALAN_HOME/serializer.jar java -classpath $CP org.apache.xalan.xslt.Process -IN $1 -XSL $2 -OUT $3 Testing. The following is an xml file called books.xml that contains data on books. It's a copy of the file found on Page 70 of the XSLT Programmer's Reference by Michael Kay. Nigel Rees Sayings of the Century 8.95 Evelyn Waugh Sword of Honour 12.99 Herman Melville Moby Dick 8.99 J. R. R. Tolkien The Lord of the Rings 22.99 We would like to transform this file into an HTML document as shown here (result.html):

A list of books

1 Nigel Rees Sayings of the Century 8.95
2 Evelyn Waugh Sword of Honour 12.99
3 Herman Melville Moby Dick 8.99
4 J. R. R. Tolkien The Lord of the Rings 22.99
In order to carry out this transformation, we will use the XSLT programming language. While it is the case that XSLT is Turing complete, that is, we can solve a wide variety of problems using XSLT, it is especially good at performing XML transformations. Our first XSLT program looks like this (booklist.xsl):

A list of books

Place the two files (books.xml and booklist.xsl) into a directory and make sure that xalan is working properly by running the following command. The output file should look like result.html. xalan books.xml booklist.xsl result.html When debugging XSLT programs, it is often much more helpful to view your output in an editor like Notepad rather than to view your output in a browser like Netscape or IE or Safari. Look at the HTML document in a browser only after you are satisfied with the way it looks in Notepad. The browser view is often quite deceiving and makes a poor debugging tool. Part 2 Handling Namespaces ========================== Many documents make use of XML namespaces to remove ambiguity. The following is our books example with a namespace assigned to the namespace prefix p. Nigel Rees Sayings of the Century 8.95 Evelyn Waugh Sword of Honour 12.99 Herman Melville Moby Dick 8.99 J. R. R. Tolkien The Lord of the Rings 22.99 The same XSLT program that we wrote above needs to be adapted to handle these namespace qualified elements. Be sure to test this new program against the books file with namespaces.

A list of books

Part 3 Running Xalan from within Java ============================================ While command line xalan makes a very nice tool, it is often necessary to make calls for XSLT processing from within other programs. Here is a Java program that performs the same transformation as above. But this time the transformation is performed under application program control. This program would be executed with the command: java ProduceHTML books.xml booklist.xsl result.html // ProduceHTML.java is a simple program that demonstrates how XSLT programs // can be executed from within Java. import java.io.IOException; import java.io.OutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.Result; import javax.xml.transform.TransformerFactory; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; public class ProduceHTML { public static void main(String a[] ) { Source xmlDoc, xslDoc; Result result; try { FileInputStream xml = new FileInputStream(a[0]); FileInputStream xsl = new FileInputStream(a[1]); FileOutputStream out = new FileOutputStream(a[2]); xmlDoc = new StreamSource(xml); xslDoc = new StreamSource(xsl); result = new StreamResult(out); TransformerFactory factory = TransformerFactory.newInstance(); Transformer trans = factory.newTransformer(xslDoc); trans.transform(xmlDoc,result); } catch(TransformerException e) { System.out.println("Transformer Probem" + e); } catch(IOException e) { System.out.println("An I/O problem"); } } } Part 4. Running XSLT from within a Java servlet. ================================================ Suppose we want to use a local stylesheet called XSLTransformerCode.xsl to process a remote XML file at some URL. Using Netbeans and Glassfish, add the xsl stylesheet file to the project's Web Pages folder. A doGet method might have the following code: PrintWriter out = response.getWriter(); // get the xsl stored in this project ServletContext context = getServletContext(); InputStream xsl = (InputStream) (context.getResourceAsStream("/XSLTransformerCode.xsl")); // We need two source objects and one result // get an external xml document using a url in a // string format Source xmlDoc = new StreamSource(urlAsString); Source xslDoc = new StreamSource(xsl); Result result = new StreamResult(out); // Prepare to transform TransformerFactory factory = TransformerFactory.newInstance(); Transformer trans = factory.newTransformer(xslDoc); trans.transform(xmlDoc,result); // The transformed document is returned to the browser. Part 5. An Atom document from the W3C ===================================== The following document was accessed from the W3C's main web page by clicking on the syndicate link. It is meant to be read by a news reader. We will use it as our input file for the homework problems below. The current W3C feed may be accessed here: http://www.w3.org/News/atom.xml W3C News tag:www.w3.org,2008-09-29://4 2013-09-06T16:31:45Z Movable Type 4.34-en Two Drafts in Last Call: N-Triples, N-Quads tag:www.w3.org,2013://4.9932 2013-09-06T16:24:32Z 2013-09-06T16:24:32Z The RDF Working Group has published two Last Call Working Drafts: N-Triples. N-Triples is a line-based, plain text format for encoding an RDF graph. Comments are welcome through 14 October. N-Quads. N-Quads is a line-based, plain text format for encoding... W3C Staff The RDF Working Group has published two Last Call Working Drafts:

  • N-Triples. N-Triples is a line-based, plain text format for encoding an RDF graph. Comments are welcome through 14 October.
  • N-Quads. N-Quads is a line-based, plain text format for encoding an RDF dataset. Comments are welcome through 14 October.

Learn more about the Semantic Web Activity.

]]>
Updated Techniques for Web Content Accessibility Guidelines (WCAG) 2.0 and Understanding WCAG 2.0 tag:www.w3.org,2013://4.9931 2013-09-05T20:26:31Z 2013-09-05T20:26:31Z The Web Content Accessibility Guidelines Working Group today published updates of two Notes that accompany WCAG 2.0: Techniques for WCAG 2.0 and Understanding WCAG 2.0. (This is not an update to WCAG 2.0, which is a stable document.) For background,... W3C Staff The Web Content Accessibility Guidelines Working Group today published updates of two Notes that accompany WCAG 2.0: Techniques for WCAG 2.0 and Understanding WCAG 2.0. (This is not an update to WCAG 2.0, which is a stable document.) For background, important information about techniques, and opportunities to contribute to future updates, please see the Understanding Techniques for WCAG Success Criteria e-mail. Read about the Web Accessibility Initiative (WAI).

]]>
Last Call: Media Source Extensions tag:www.w3.org,2013://4.9930 2013-09-05T20:16:36Z 2013-09-05T20:16:36Z The HTML Working Group has published a Last Call Working Draft of Media Source Extensions. This specification extends HTMLMediaElement to allow JavaScript to generate media streams for playback. Allowing JavaScript to generate streams facilitates a variety of use cases like... W3C Staff The HTML Working Group has published a Last Call Working Draft of Media Source Extensions. This specification extends HTMLMediaElement to allow JavaScript to generate media streams for playback. Allowing JavaScript to generate streams facilitates a variety of use cases like adaptive streaming and time shifting live streams. If you wish to make comments or file bugs regarding this document in a manner that is tracked by the W3C, please submit them via our public bug database. Comments are welcome through 17 October. Learn more about the HTML Activity.

]]>
Guidance on Applying WCAG 2.0 to Non-Web ICT: WCAG2ICT Note Published tag:www.w3.org,2013://4.9929 2013-09-05T20:10:51Z 2013-09-05T20:10:51Z The Web Content Accessibility Guidelines Working Group is pleased to announce publication of the completed Guidance on Applying WCAG 2.0 to Non-Web Information and Communications Technologies (WCAG2ICT) as an informative W3C Working Group Note. WCAG2ICT provides guidance on the interpretation... W3C Staff The Web Content Accessibility Guidelines Working Group is pleased to announce publication of the completed Guidance on Applying WCAG 2.0 to Non-Web Information and Communications Technologies (WCAG2ICT) as an informative W3C Working Group Note. WCAG2ICT provides guidance on the interpretation and application of WCAG 2.0 to non-web documents and software. It is the result of a collaborative effort to support harmonized accessibility solutions across a range of technologies. Learn more from the WCAG2ICT Overview and read about the Web Accessibility Initiative (WAI).

]]>
Media Capture and Streams Draft Published tag:www.w3.org,2013://4.9927 2013-09-03T15:29:03Z 2013-09-03T15:29:03Z The Web Real-Time Communication Working Group and the Device APIs Working Group have published an updated Working Draft of Media Capture and Streams. This document defines a set of JavaScript APIs that allow local media, including audio and video, to... W3C Staff The Web Real-Time Communication Working Group and the Device APIs Working Group have published an updated Working Draft of Media Capture and Streams. This document defines a set of JavaScript APIs that allow local media, including audio and video, to be requested from a platform. Learn more about the Ubiquitous Web Applications Activity.

]]>
Registration Open for HTML5 Training Course; Early Bird Rate through 8 September tag:www.w3.org,2013://4.9926 2013-08-28T16:08:59Z 2013-08-28T16:08:59Z Register now to the upcoming W3C HTML5 online course, to start 30 September 2013. Acclaimed trainer Michel Buffa will cover the techniques developers and designers need to create great Web pages and apps. This new course edition has been significantly... W3C Staff Register now to the upcoming W3C HTML5 online course, to start 30 September 2013. Acclaimed trainer Michel Buffa will cover the techniques developers and designers need to create great Web pages and apps. This new course edition has been significantly enhanced since the June 2013 course. It features additional sections, including a JavaScript crash course, advanced sections on time based animation, 2D geometric transformations, Web Audio API, etc., all illustrated by numerous examples. Register before September 8 to benefit from the early bird rate. Learn more about W3DevCampus, the W3C online training for Web developers.

]]>
Public Identifiers for entity resolution in XHTML Draft Published tag:www.w3.org,2013://4.9922 2013-08-22T18:06:26Z 2013-08-22T18:06:26Z The HTML Working Group has published a Working Draft of Public Identifiers for entity resolution in XHTML. This document adds an additional public identifier that should be recognised by XHTML user agents and cause the HTML character entity definitions to... W3C Staff The HTML Working Group has published a Working Draft of Public Identifiers for entity resolution in XHTML. This document adds an additional public identifier that should be recognised by XHTML user agents and cause the HTML character entity definitions to be loaded. Unlike the identifiers already listed by the HTML5 specification, the identifier added by this extension references the set of defintions that is used by HTML. Learn more about the HTML Activity.

]]>
WebCrypto Key Discovery Working Draft Published tag:www.w3.org,2013://4.9920 2013-08-22T16:40:18Z 2013-08-22T16:40:18Z The Web Cryptography Working Group has published a Working Draft of WebCrypto Key Discovery. This specification describes a JavaScript API for discovering named, origin-specific pre-provisioned cryptographic keys for use with the Web Cryptography API. Pre-provisioned keys are keys which have... W3C Staff The Web Cryptography Working Group has published a Working Draft of WebCrypto Key Discovery. This specification describes a JavaScript API for discovering named, origin-specific pre-provisioned cryptographic keys for use with the Web Cryptography API. Pre-provisioned keys are keys which have been made available to the user agent by means other than the generation, derivation, importation functions of the Web Cryptography API. Origin-specific keys are keys that are available only to a specified origin. Named keys are identified by a name assumed to be known to the origin in question and provisioned with the key itself. Learn more about the Security Activity.

]]>
Three RDFa Recommendations Published tag:www.w3.org,2013://4.9919 2013-08-22T16:15:02Z 2013-08-22T16:15:02Z The RDFa Working Group today published three RDFa Recommendations. RDFa lets authors put machine-readable data in HTML documents. Using RDFa, authors may turn their existing human-visible text and links into machine-readable data without repeating content. Today's publications were: HTML+RDFa... W3C Staff Semantic Web Cube The RDFa Working Group today published three RDFa Recommendations. RDFa lets authors put machine-readable data in HTML documents. Using RDFa, authors may turn their existing human-visible text and links into machine-readable data without repeating content. Today's publications were:

  • HTML+RDFa 1.1, which defines rules and guidelines for adapting the RDFa Core 1.1 and RDFa Lite 1.1 specifications for use in HTML5 and XHTML5. The rules defined in this specification not only apply to HTML5 documents in non-XML and XML mode, but also to HTML4 and XHTML documents interpreted through the HTML5 parsing rules.
  • The group also published two Second Editions for RDFa Core 1.1 and XHTML+RDFa 1.1, folding in the errata reported by the community since their publication as Recommendations in June 2012; all changes were editorial.
  • The group also updated the a RDFa 1.1 Primer.

Learn more about the Semantic Web Activity.

]]>
Last Call: Internationalization Tag Set (ITS) Version 2.0 tag:www.w3.org,2013://4.9918 2013-08-21T12:11:34Z 2013-08-21T12:11:34Z The MultilingualWeb-LT Working Group has published a Last Call Working Draft of Internationalization Tag Set (ITS) Version 2.0. ITS 2.0 makes it easier to integrate automated processing of human language into core Web technologies. ITS 2.0 focuses on HTML, XML-based... W3C Staff The MultilingualWeb-LT Working Group has published a Last Call Working Draft of Internationalization Tag Set (ITS) Version 2.0. ITS 2.0 makes it easier to integrate automated processing of human language into core Web technologies. ITS 2.0 focuses on HTML, XML-based formats in general, and can leverage processing based on the XML Localization Interchange File Format (XLIFF), as well as the Natural Language Processing Interchange Format (NIF). Comments are welcome through 10 September. Learn more about the Internationalization Activity.

]]>
W3C Launches Web and Mobile Interest Group tag:www.w3.org,2013://4.9917 2013-08-20T17:47:57Z 2013-08-20T17:47:57Z W3C launched today a Web and Mobile Interest Group that is chartered to accelerate the development of Web technology so that it becomes a compelling platform for mobile applications and the obvious choice for cross platform development. The forum is... W3C Staff W3C launched today a Web and Mobile Interest Group that is chartered to accelerate the development of Web technology so that it becomes a compelling platform for mobile applications and the obvious choice for cross platform development. The forum is intended to include organisations that commission such products and services, designers, developers, equipment manufacturers, tool and platform vendors, browser vendors, operators and other relevant participants in the value chain that creates and operates such products and services. Participants will focus on a wide range of sectors including retail, advertising, technology, network operators, content creation and content distribution.

The initial deliverables of the group include:

  • Core Mobile Web Platform 2012 Deployment Status, which will summarize the various actions that the Interest Group is undertaking to ensure that the relevant stakeholders facilitate the deployment and adoption of the features that have been identified in the Core Mobile Web Platform 2012 report. The group will also publish new versions of the report
  • Standards for Web Applications on Mobile: current state and roadmap, which will take a broader look at all the Web technologies under development that are particularly relevant to mobile devices, and tracks their status and adoption.
  • A gap analysis that provides an overview of the differences between the Web as a platform on mobile and other popular platforms and ecosystems, both from a technical and commercial perspective.
  • Additional reports on use cases and scenarios for context-relevant user experiences, multi-device and cross-device user experiences on the Web, and Usability and Efficiency Considerations for the Web on Mobile.

Read more about the Mobile Web Initiative.

]]>
Push API and Input Method Editor API Drafts Published tag:www.w3.org,2013://4.9915 2013-08-15T18:48:36Z 2013-08-15T18:48:36Z The Web Applications Working Group has published two Working Drafts: Push API. This specification defines a “Push API” that provides webapps with scripted access to server-sent notifications, for simplicity referred to here as push notifications, as delivered by push services.... W3C Staff The Web Applications Working Group has published two Working Drafts:

  • Push API. This specification defines a “Push API” that provides webapps with scripted access to server-sent notifications, for simplicity referred to here as push notifications, as delivered by push services. Push services are a way for application servers to send messages to webapps, whether or not the webapp is active in a browser window.
  • Input Method Editor API. This specification defines an “IME API” that provides Web applications with scripted access to an IME (input-method editor) associated with a hosting user agent.

Learn more about the Rich Web Client Activity.

]]>
W3C Workshop Report: Smart Homes, Cars, Devices and the Web - Rich Multimodal Apps tag:www.w3.org,2013://4.9914 2013-08-14T12:20:33Z 2013-08-14T12:20:33Z W3C published today a summary of the Workshop on Rich Multimodal Application Development, hosted by Openstream on 22-23 July in the New York Metropolitan Area. One of the Workshop aims was to accentuate the merits of HTML5 and the W3C... W3C Staff W3C published today a summary of the Workshop on Rich Multimodal Application Development, hosted by Openstream on 22-23 July in the New York Metropolitan Area.

One of the Workshop aims was to accentuate the merits of HTML5 and the W3C Multimodal Architecture to help create the appropriate level of awareness of the maturity of the MMI Architecture and its suitability for developing innovative and compelling user-experiences across applications/devices.

Workshop participants prioritized work on use cases and requirements for rich multimodal applications, including service/device discovery, HTML5 integration, extending EMMA for output, specific industry snapshot, streaming, timing handling and related standards.

As discussed during the workshop, the W3C Multimodal Interaction Working Group will hold Webinars like the one held in January to discuss the issues identified during the workshop with all the stakeholders. Learn more about the Multimodal Interaction Activity.

]]>
HTML5 and Canvas 2D Candidate Recommendations Updated by the HTML Working Group tag:www.w3.org,2013://4.9911 2013-08-06T17:24:29Z 2013-08-06T17:24:29Z The HTML Working Group updated two Candidate Recommendations today: HTML5, which defines the 5th major revision of the core language of the World Wide Web, the Hypertext Markup Language (HTML). In this version, new features are introduced to help Web... W3C Staff The HTML Working Group updated two Candidate Recommendations today:

  • HTML5, which defines the 5th major revision of the core language of the World Wide Web, the Hypertext Markup Language (HTML). In this version, new features are introduced to help Web application authors, new elements are introduced based on research into prevailing authoring practices, and special attention has been given to defining clear conformance criteria for user agents in an effort to improve interoperability.
  • HTML Canvas 2D Context, which defines the 2D Context for the HTML canvas element. The 2D Context provides objects, methods, and properties to draw and manipulate graphics on a canvas drawing surface.

Learn more about the HTML Activity.

]]>
W3C Highlights - August 2013 tag:www.w3.org,2013://4.9910 2013-08-01T20:30:48Z 2013-08-01T20:30:48Z Today, W3C published W3C Highlights - August 2013, a survey of select recent work and upcoming priorities. The report includes: progress and work ahead in making the Open Web Platform a success on mobile devices, news in Web for All... W3C Staff Today, W3C published W3C Highlights - August 2013, a survey of select recent work and upcoming priorities. The report includes: progress and work ahead in making the Open Web Platform a success on mobile devices, news in Web for All areas like accessibility and internationalization, how W3C is collaborating more closely with various industries that are being transformed by the Web, liaison updates, and new opportunities for more people to get involved in W3C.

]]>
PART 6 Introductory XSLT Programming ==================================== In solving the Atom puzzles below, I used the following in each of my XSLT programs. (1) 2.5 Points. Using command line XSLT, write an XSLT program that displays the contents of each title that is a direct child of feed/entry. This list of titles will appear as an HTML unsigned list. No variables may be used in your style sheet. It will appear something like this (newlines added for readability):

W3C Atom Document

(2) 2.5 Points. Modify the program in question (1) so that the titles are in sorted order. This first two titles in my browser are: Guidance on Applying WCAG 2.0 to Non-Web ICT: WCAG2ICT Note Published HTML5 and Canvas 2D Candidate Recommendations Updated by the HTML Working Group (3) 5 Points. This is exactly the same as question 1 but you are required to use a global variable in your XSLT style sheet. See the article "What kind of language is XSLT?" by Michael Kay (writing for IBM on the course schedule). It is required that you use the following variable declaration: You will then dereference the variable in the element. (4) 10 Points. Using command line XSLT, write an XSLT program that displays the number of Atom entry elements that appear in the document. You must use the XSLT count function in your solution. Your output will be marked up as HTML and will appear in a browser as follows: Counting Atom entry items 15 (5) 10 Points. Using command line XSLT, write an XSLT program that displays the contents of each title that is a direct child of feed/entry. Your output will be marked up as HTML and will appear in a browser with the titles underlined as hypertext links. If the user clicks on a link the browser will fetch the associated document that is pointed to by the link element. The output on the browser will appear as follows (in a browser, these show up as clickable links.) Titles (with links) * Two Drafts in Last Call: N-Triples, N-Quads * Updated Techniques for Web Content Accessibility Guidelines (WCAG) 2.0 and Understanding WCAG 2.0 * Last Call: Media Source Extensions (6) 5 Points. Using command line XSLT, write an XSLT program that displays the contents of each title and the value of the term attribute of each category associated with that title. The output will be marked up nicely in HTML. A browser will display something like the following: Titles and Categories Two Drafts in Last Call: N-Triples, N-Quads Semantic Web Home Page Stories Publication Updated Techniques for Web Content Accessibility Guidelines (WCAG) 2.0 and Understanding WCAG 2.0 Home Page Stories Publication Web Design and Applications (7) 2.5 Points. This is the same as question (6) but generate a JSON object instead of HTML. SERVER SIDE MASHUP Reading RSS ============================== (8) 30 Points. Write a JSP page that asks the user to enter a topic from a list of topics shown in a drop down list. The three topics will be Business, Technology and World News. Once a selection is made your browser will make a call on a Java servlet passing along the topic. The topic is simply a string passed to the servlet from the browser. The servlet will fetch the appropriate RSS 2.0 feed from the NY Times web site. It will apply a style sheet that will generate HTML to the browser. The HTML display will show each news title of each item. Each news title will be displayed as a link. The user will be able to click links to visit the associated page. Note that there are no namespaces defined on the main elements in RSS 2.0. New York Times feeds may be found at http://www.nytimes.com/services/xml/rss/index.html (9) 10 Points. Add a source of feeds drop down box to the application that you built in question 8. Thus, the user will be able to select a topic and a source. At a minimum, you will need to provide for three sources. In my solution, I used the BBC, the New York Times and the Sydney Morning Herald. The BBC feeds are discussed here: http://news.bbc.co.uk/1/hi/help/3223484.stm The Sydney Morning Herald feeds are discussed here: http://www.smh.com.au/rssheadlines If you answered question 9 there is no need to turn in an answer to question 8. Simply turn in your work for question 9. (10) 10 points. Add Ajax to your solution in question 9. Be creative and redesign the site so that there is no need for a full page refresh. If you answered question 10 there is no need to turn in an answer to question 9. Simply turn in your work for question 10. (11) 10 points. Use the JQuery Javascript library in a way that adds value to your RSS web application in question 10. Here is an introduction to JQuery that shows how the library can be included in your Netbeans project: http://netbeans.org/kb/docs/web/js-toolkits-jquery.html Note: You may combine (10) and (11) and use JQuery for your Ajax calls. Or, you might use JQuery for something else. In either case, if you have answered question 11, you need not submit an answer to question 10. Simply submit an answer to question 11. (12) 2.5 Points. Modify the KML file found on the Course Schedule, TravelingSalesPersonProblem.kml, so that it draws a shape on Google Earth in the Pittsburgh area.