Getting Started with XML and XML Editors

Assignment 1 — XML Foundations (INFOSYS 242; Fall 2006)

Assigned: 2006-09-05 / Due: 2006-09-12

Authors: Bob Glushko & Erik Wilde / TA: Katrina Rhoads Lindholm

Introduction: This assignment introduces you to XML in the context of XML Spy or the oXygen XML Editor. You don't have to turn anything in. However, you should use this opportunity to get comfortable with one of the two editors, as you will be using them for the rest of the semester, and maybe the rest of your life.
Resource: Sample Files
Instructions:

XML Spy: XML Spy is an award-winning XML editor and development environment that has been generously provided to SIMS for use in Document Engineering and XML courses by Altova, headquartered in Vienna, Austria. XML Spy is installed on all of the computers in the SIMS computing lab on the 2nd floor of South Hall. You can use XML Spy as the primary tool for creating XML, XML schemas, XML stylesheets and transforms, and so on. You can use XML Spy in the SIMS lab or you can download it from http:/www.xmlspy.com and install it on your own computer. The 30-day license you get when you download it will run out after this short course is over. XML Spy runs only on Windows.

oXygen: If you don't use Windows, or would prefer another editor, SyncRO Soft, a Romanian software company, has a product called oXygen XML. While the editor has fewer features than XML Spy, it has other benefits. It runs within a Java Virtual Machine, so it runs on any platform with a Java Runtime Environment. And despite its dependency on Java, it uses less system resources than XML Spy. You can download the trial version from http://www.oXygenxml.com/. You can also get a version with less features, that runs within Eclipse.

Using XML Spy

Find XML Spy in (some directory) and start it up.

You will be working with three files: Report.xml, Report.dtd, and Report.xsl. These three files must be in the same directory

Open an XML instance in the editor. (Report.xml)

Open the XML instance in a browser (IE or Mozilla). Why is it rendered this way? (View > Source on menu bar).

In XML Spy, check the XML instance for well-formedness. (F7). XML is more rigorous than HTML. Delete the <Name> tag. Is the instance well-formed? Change <Para> to <para>. Is the instance well-formed? Omitting end tags and mixed case tags aren't a problem in HTML but XML won't allow it. Undo these changes so that your instance is well-formed again.

Specify an XML Document Type Definition for the XML instance by inserting <!DOCTYPE Report SYSTEM "Report.dtd"> directly below the <?xml version="1.0" encoding="UTF-8"?> declaration at the top of the file.

Validate the XML instance. (F8). Insert a second author element containing your name and email. Is this valid? Insert a <Phone> tag, your phone number, and </Phone> after your email element. Is this valid?

Open the XML DTD in the editor. The syntax is a little strange but has some resemblance to the BNF you probably know from programming languages. Could you have answered the previous questions by examining the DTD rather than by experimentation?

Specify a style transformation for the XML instance by inserting as the third line of the instance <?xml-stylesheet type="text/xsl" href="Report.xsl"?>

Open the XML instance in a browser again. It should be formatted this time. Delete the DTD specification. Does the style transform still work? What does this imply about XML transformation programs?

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?

Using oXygen XML

Find oXygen XML in (some directory) and start it up.

Open an XML instance in the editor. (Report.xml)

You will be working with three files: Report.xml, Report.dtd, and Report.xsl. These three files must be in the same directory

Open the XML instance in a browser (IE, Mozilla). Why is it rendered this way? (View > Source on menu bar).

In oXygen XML, check the XML instance for well-formedness (click the blue-checked document icon, second from the left, in the tool bar immediately above your instance). XML is more rigorous than HTML. Delete the <Name> tag. Is the instance well-formed? Change <Para> to <para>. Is the instance well-formed? Omitting end tags and mixed case tags aren't a problem in HTML but XML won't allow it. Undo these changes so that your instance is well-formed again.

Specify an XML Document Type Definition for the XML instance by inserting <!DOCTYPE Report SYSTEM "Report.dtd"> directly below the <?xml version="1.0" encoding="UTF-8"?> declaration at the top of the file.

Validate the XML instance (click the red-checked document icon, on the left of the well-formedness icon). Insert a second author element containing your name and email. Is this valid? Insert a<Phone> tag, your phone number, and </Phone> after your email element. Is this valid?

Open the XML DTD in the editor. The syntax is a little strange but has some resemblance to the BNF you probably know from programming languages. Could you have answered the previous questions by examining the DTD rather than by experimentation?

Specify a style transformation for the XML instance by inserting as the third line of the instance <?xml-stylesheet type="text/xsl" href="Report.xsl"?>.

Now that you have inserted this instruction, you can transform your XML instance. Click the red-triangle-in-a-circle icon. This should open up a web browser and display Report.xml after transformation, or open it up in results window immediately below the document, depending on what the defaults are set to. Delete the DTD specification. Does the style transform still work? What does this imply about XML transformation programs?

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?


please send comments to dret@sims.berkeley.edu
last modification on Sunday, 10-Dec-2006 01:24:15 MET
valid CSS! valid XHTML 1.0!