Web Design/XML challenges

The following challenges will help you familiarise yourself with a few other applications of XML (other than the XHTML that you've already been doing!)

Challenge 1: Getting to know SVG
Copy the following file into your editor of choice and save it as myfirstsvg.svg, then open up the file in a browser (Internet Explorer with the Adobe SVG plugin, Firefox 1.5+, Opera 9+, Safari 3+, or Chrome):

Assuming this is the first time you've seen an SVG file, you might notice that it looks very similar to an HTML file, but with some obvious differences!
 * 1) Change the rectangle so that it's filled with yellow
 * 2) Make the rectangle's border a bit bigger and modify the color of the border (let's say, green!)
 * 3) Any ideas what the fill-opacity might do? Test it out.
 * 4) See if you can turn your rectangle into a square
 * 5) Finally, can you modify the position of your rectangle?

Easy?!

Challenge 2: More SVG elements
Still using the same SVG file (myfirstsvg.svg), add the following element to your SVG:

Test it out and see if it does what you expect! Looks a bit boring though! Add some plain old CSS style, so that Note, you can also use CSS pseudo selectors, like :hover to change your shapes when the mouse hovers over them! (for eg: circle:hover {fill-opacity:0.3} )
 * 1) your circle is filled with the color Blue,
 * 2) your circle has a stroke similar to your rectangle
 * 3) your circle has an opacity of 0.7

Finally, see how you go arranging the Olympics logo:
 * 1) Add another 4 circles to your file (you might want to 'translate' them so that they aren't all on top of each other)
 * 2) Give each circle an id, just like you would an HTML element, then use this ID to make each circle a different colour.
 * 3) Arrange the colours and the positions of your circles to form the Olympic logo

Challenge 3: Animating the Olympics with SVG!
Animating shapes in SVG is really easy! There's actually a tag called animateTransform to help us out, but unfortunately it's not yet supported by Firefox's native SVG, so we'll need to install the Adobe SVG plugin or Opera 9+.

Note that the animateTransform element goes inside the circle element! (Watch out for this, make sure that you don't close your circle element before your animateTransform element).

Modify one of your circles as follows:

Now,
 * 1) Try playing with the 'from', 'to', 'begin' and 'dur' attributes, testing to see what they do.
 * 2) When you feel ready, have a go at creating an animation where 5 circles animate to form the Olympic logo! Your circles should all begin at the side of the page, and then animate to form the Olympic logo!

Challenge 4: Roll your own RSS feed
RSS is a family of web feed formats, specified in XML and used for Web syndication. RSS is used by (among other things) news Web sites, weblogs and podcasting. No one can really decide what it stands for (either Really Simple Syndication, Rich Site Summary or RDF Site Summary)

Web feeds provide web content or summaries of web content together with links to the full versions of the content, and other metadata. RSS, in particular, delivers this information as an XML file called an RSS feed, webfeed, RSS stream, or RSS channel. In addition to facilitating syndication, web feeds allow a website's frequent readers to track updates on the site using an aggregator. (see the Wikipedia RSS article for more information.)

You've probably already been using newsfeeds to keep up-to-date with the world of web design, using Bloglines or another news reader.

In this activity, you'll follow a tutorial to create your own RSS news feed for your site! The article Really Simple Syndication will help you familiarise with the basic tags that are used with RSS as well as step you through creating your own RSS file.

After reading through the article in overview,
 * 1) Create a new blank RSS file of your own and save it as feed.xml
 * 2) Work through the "Building a personal RSS Feed, step-by-step" section of the article Really Simple Syndication to create your own RSS feed for your own site. Try to make sure you've got 3 or 4 items in your feed. They might point to different sections of your site.
 * 3) Once you're happy with your file you'll want to validate your file to make sure you haven't forgotten any closing tags etc. RSS feeds can be validated just like web pages using the feed validator. Copy and paste the text of your rss feed into the validator and see what happens!
 * 4) Upload your feed onto your websites main folder
 * 5) Finally, verify that your feed works by adding it to your Bloglines account (or other feed reader).

While we're on the subject: For fun, try and get a Microsoft Excel spreadsheet to display RSS-feeds.

Challenge 5: Adding some maths to your pages
Just to see how easy it is to combine XML languages, create a new file with the following code, and save it as mathmltest.xml (Note the .xml extension, not .html). Open the file in Firefox and test the result.

(Note, the following example is simplified a little, for the full details visit the W3 specification).

Unfortunately MathML gets a bit too complicated to do anything too flash yet, so the following challenges just help apply the above example. Try adding an extra section to your file for each of the challenges below:

A more complicated fraction

$$x = -\frac{b}{2a} \ $$

An advanced equation (hard)

$$x_ = \frac{-b + (b^2-4ac)}{2a}. $$

Here is a site which generates Math ML using simple computer symbols to make the equation and then translates it. MathML Central

What is a Sitemap for?
First we need to find out what a Google sitemap is for. In summary, What is a Sitemap and why should I have one? from Google says:

A Sitemap file lets you tell us about all the pages on your site, and optionally, information about those pages, such as which are most important and how often they change. By submitting a Sitemap file, you can take control of the first part of the crawling/indexing processes: our discovery of the pages.

What does the XML Sitemap file look like?
Then find out what the XML file should look like: Using the sitemap protocol (This page also has an example of a Google sitemap).

Now you may be ready to:
 * Create a Google sitemap for a small site of yours (perhaps your portfolio site)
 * Validate your sitemap using smart-it-consulting's free validator.

How do I submit my google sitemap?
Once you've created your sitemap, you can follow the instructions on About Google Sitemaps to learn where abouts your file needs to go on your server and how to submit it with Google.

Challenge 7: An XML file to store CD's (or Movies, or Model airplanes)
So far we've created XML files where the format of the XML has already been specified by someone else. For example, when we created our SVG file, someone else had already specified that  and   are valid elements (but   is not!). Take a minute now to go back and see what elements were allowed for:
 * RSS.
 * MathML.
 * your Google site map.
 * XHTML. (You should be able to name lots of valid elements for XHTML!)

Now it's time to create your own XML file, where you make up your own descriptive elements! Here's an example of an XML document describing a school class:

Your challenge is to create an XML file to describe the relevant information from one of the following:
 * A CD album
 * A DVD library (just include the info from 2 or 3 DVD's)
 * A product catalogue from a shop of your choice. (again, just include the info from 2 or 3 products)
 * Something of your own choice (check with your facilitator)

The key problem that you will face is deciding the best way to structure your XML file (as there will be many ways you can do it!) When you've finished, it will be very helpful to get together with others and discuss your decisions.

Interlude: Well-formed XML versus valid XML
Question: What are the key rules that you need to follow when creating any XML document (such as the XHTML we've been creating since day one!):
 * 1) Every element must have an opening and closing tag.
 * 2) Each document must have one and only one root element.
 * 3) Attributes must have either single or double quotes around the text.
 * 4) Special characters must be escaped (<, >, &, " and ').

These requirements actually ensure that the XML document is well-formed. If you didn't manage to identify five or six requirements (or even if you did), do a bit of research to find out what the requirements for a well-formed xml (or xhtml) document are. Hopefully you'll find that you've been doing these since you started to learn XHTML!

But does it mean that your document is valid? Here's an example snippet of some XHTML that uses mixed content:

Now here's a snippet of XHTML that is well-formed and uses mixed content.

OK, so that example might be very obvious, here's another snippet of XHTML that is well-formed but also uses mixed content.

A file is valid if it passes validation with an XML Schema.

Challenge 8: Editing an XML Doctype
For a long time, you've added the following line to your XHTML files: but do you know what it actually does? We're going to find out in this challenge! It's called a Document Type Declaration (or DTD for short).

W3Schools have a great introduction to DTD's that provides an example with an explanation. Read through this introduction and then:
 * Copy-n-paste the w3schools example XML file with the embedded DTD into the W3Schools XML validator and check that it validates (Note: You'll need to use Internet Explorer).
 * Now change the &lt;from&gt; element to &lt;sender&gt; (both the opening and closing tags). Try validating now... even though your XML file is well-formed, does it validate?

Now, consider the following XML file:

Challenges:
 * Create a DTD for this XML file and test that it works (using the validator).
 * Make a copy of your file, and using the info from the W3Schools intro to modify your file so that it uses an external DTD. Upload your XML file and DTD to your hosting and validate it (again using the W3Schools XML validator).

Extra challenges (for the keen!)
 * Improved the way Date's are stored in the XML file, and update the DTD accordingly
 * Create a DTD for your XML file that you created in Challenge 7. You can use the W3Schools validator to validate your own file too!

Challenge 9: (Optional) Creating an XML Schema
XML Schemas allow you to validate the structure of XML documents. Unlike DTDs, XML Schemas also have data types that can be associated with each of the "leaves" of your document tree. XML Schemas are usually created with graphical modeling tools but advanced users can also enter them using a text editor.