Assignment 4 – XML

Due 10/1

This purpose of this assignment is to get you familiar with one of the two editors and understand how an XML instance, schema, and transform fit together.

XML Spy (Windows)https://www.ischool.berkeley.edu/intranet/computing/software/xmlspy

XML Spy is an award-winning XML editor and development environment that has been generously provided to the I School for use in courses and projects, but it runs only on Windows or on Mac/Linux using a Windows emulator.

oXygen (Mac / Linux)https://www.ischool.berkeley.edu/intranet/computing/software/oxygen

oXygen XM  runs within a Java Virtual Machine, so it runs on any platform with a Java Runtime Environment. You can use the I School’s license to install it on your own computer.

Part 0:

This section is not graded, but will instruct you on how to use XML and the XML editors. The listed questions don’t need to be answered, but are here to help you think about and understand XML

  1. Install XML Spy or oXygen

  2. Download the attached zip file, which contains:
    Report.xml: an XML instance
    Report.dtd: an XML Document Type Definition
    Report.xsl: an XML transformation file

  3. Open Report.xml in the editor.

  1. Also open Report.xml in a web browser. Why is it rendered this way? (“View > Source” on menu bar).

  2. Back in the editor, check the XML instance for “well-formedness” – conformance to the syntax rules for XML (F7 in XML Spy; in oXygen, click the blue-checked document icon in the tool bar).

  1. Delete the beginning <Name> tag. Is the instance still well-formed?
    Change <Para> to <para>. Is the instance well-formed?
    XML is enforcing more restrictive syntax rules than HTML. Or put another way, XML doesn’t allow bad practices that browsers typically forgive with HTML.
    Undo these changes so that your instance is well-formed again.

  1. Specify an XML Document Type Definition for the XML instance by inserting

    
    

    directly below the

    declaration at the top of the file.

  1. Validate the XML instance. (F8 in XML Spy; in oXygen, use the red-checked document icon, near the well-formedness icon). Insert a second author element containing your name and email. Is this valid?

  1. Insert a <Phone> tag, your phone number, and </Phone> after your email element. Is this valid?

  1. Open the XML DTD in the editor. Try to figure out how you could have answered the previous two questions by examining the DTD rather than by experimentation.

  1. Specify a style transformation for the XML instance by inserting as the third line of the instance

  2. Open the XML instance in a browser again (in XML Spy, you can do this by clicking the “Browser” button at the bottom of the editor pane; in oXygen, click the red-triangle-in-a-circle icon to the right of the well-formedness icon).
    It should be formatted this time.

  1. Delete the DTD specification. Does the style transform still work?
    What does this imply about XML transformation programs?

  1. Open the XML transformation file (Report.xsl) in the editor.
    The third line of the program (where “xsl:template” occurs) matches the element named “Report” in the instance and then passes through as output everything up to the next “xsl:template” tag.

    Can you see how these 20 lines or so create the HTML “scaffold” for the formatted report?

Part 1 (4 points):

Rename a copy of Report.xml to YourlastnameA4.xml (e.g., GlushkoA4.xml).
Change the Author information to your own.

Note: You will have another section for your reflections from Part 2, listed below.

In the Body section of the report, change the Section title to “Reflections on Assignment 4” and write a short paragraph which:

  • Describes (using 202 terms) what each of the three files we gave you does. (2 points)

  • Explains the difference between an XML instance and the Document Type Definition. (1 point)

Validate your Report document and transform it to HTML. (1 point)

Part 2 (6 points):

Now that you have a feel for working in XML, we are asking you to return to A3 and encode the an instance of the vocabulary you submitted.

If during this process you wish to change your vocabulary, feel free, but the idea is that all the conceptual work you did in A3 should transfer over seamlessly. If you do make changes to your vocabulary, clearly describe your new vocabulary and descriptors in your reflection.

Please note: we are not asking you to create a DTD. Only an instance that follows the schema you laid out in A3. Put another way, pretend that the vocabulary you created in A3 is a DTD and follow it when creating your instance. Please name your instance YourNameA4Instance.xml. (3 points)

Next, create another Section in your Reflection report in Part 1 and title it “Reflections on Encoding Your Instance”. Write a paragraph or two (depends on how much you changed) describing your experience creating your instance. (3 points)

  • Was it straightforward?

  • Did it match the instance you created for A3?

  • If not, what changed in the instance?

  • If you had to make changes to your vocabulary, what were they and why did you decide to make them?

  • Try to validate your document against Report.dtd. What happens and why?

Make sure your XML is still valid after you add this Section!

Extra Credit (up to 2 points):

Create a DTD for your vocabulary defining valid tags and attributes. Ensure that your instance validates against the DTD. Include the DTD in your submission zip with the name YourNameA4Vocabulary.dtd

Submission Instructions

Submit a total of five files (zipped). Name your zipped file YourNameA4.zip

You should include:

  • YourNameA4Instance.xml

  • YourNameA4Report.xml

  • YourNameA4Report.dtd

  • YourNameA4Report.xsl

  • YourNameA4Report.html

  • YourNameA4Vocabulary.dtd (extra credit)