Skip to content Skip to navigation

Connexions

You are here: Home » Content » P2PU Learn XSLT : Challenge 1

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

In these lenses

  • XSLT display tagshide tags

    This module is included inLens: Hannes Hirzel's XSLT Lens
    By: Hannes Hirzel

    Comments:

    "Exercise: write a XSLT style sheet which converts cnx content to HTML."

    Click the "XSLT" link to see all content selected in this lens.

    Click the tag icon tag icon to display tags associated with this content.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
 

P2PU Learn XSLT : Challenge 1

Module by: Katherine Fletcher. E-mail the author

Summary: This module is part of a P2PU course on learning XSLT 2.0.

Challenge 1: Take a little XML module and transform it to HTML

Pre-requisites

All of the techniques you will need are located in the first three chapters of Jenni Tennison's "Beginning XSLT 2.0". You don't have to have the book to complete this challenge, however. You should be able to use any of the web resources listed here, and then look up the needed techniques listed below.

The first chapter is a review of XML. If don't know much about XML, this is the chapter for you. It also has a nice review of encodings. Chapters 2 and 3 cover xsl:for-each, xsl:value-of, xsl:apply-templates, selecting, matching, modes, priorities, generating attributes and ids and xsl:next-match (a 2.0 feature). She gives a series of examples that transform an xml document describing tv channels and shows in to a simple web page displaying them. The techniques she uses can be applied directly in our challenge.

The goal

Transform a simplified CNXML module into an HTML page. The sample module contains some introductory paragraphs, some exercises, and some terminology within the exercises that are tagged as "terms". Each exercise has a title. The module also has a little bit of metadata, a title, some authors, and a license URL.

Resources

Detailed description

The input file

You will be starting with the following XML file (download it here).

The images below show some of the code

https://lh5.googleusercontent.com/f8U1E9v8GargNg0PGkf8pElcYndVNfqmK5u4EjS-SDRry8OWXumU58a41VQvESWMeDD593kVUXwsjbn-O8cvGs8g29rg1SXDsBxuT6-aROVygphuZ9M

https://lh3.googleusercontent.com/VKN2P2Q8sV2fmEDHmEUWgIo5AniQt-103PKq7xQQqBPBJQZr37vVMBkk8F7TxxC32hMxHX1gioyhk_eKHmk17NVaw0zb0uyiG31U9CL4GqkZTrvGIas

Sample output file

This is just an example of what your rendered module might look like. Be creative. This one isn't even completely done.

https://lh4.googleusercontent.com/Pr_x0EeCLEQSxtTu0_mCHfk1rXRSFRbEKzC-IjA8gmme-Al-P5BRiUxI5TFXnzonClHtpe5fEeFLYMJXDeoPXZX7EJaPtVST5_rMoIivodYZL7b8RWI https://lh5.googleusercontent.com/iRDEb3zJ0A29c85hZnPcFz1-f1UR6JSKJeXVOiB7mHaOy0jFtWdMaKC9GlrBY0AnBJXkJ3sChPXbjpcWj6S_-XjACsJLMUKAfu0HTfOvllf6uMTlOcg

Your solution should have the following components:

  • A table of contents with links to each of the exercises
  • The document output with exercises that hide their solutions initially and let you click on the them to open them.
  • A glossary at the end that lists all the terms found in the document.

The input document has a <verbatim-section> element that contains a table that we aren't processing yet. The intention is just to copy it into the output directly since it is already HTML. An easy way to copy it is to use the following template snippet. The first three chaps don't cover xsl:copy-of, so I am giving this to you.

Note: Template to copy table:
<!-- Given template to output the table as is into the html document. -->

<xsl:template match="verbatim-section">
     <xsl:copy-of select="node()"/>
</xsl:template>

Extra challenges for those already experienced with XSLT

  • Use the next-match feature
  • Number the exercises using XSLT and using CSS.
  • Any other cool features and interactions you want to throw in.
  • Add an exercise that doesn't have a solution and make sure it is properly handled. Ex. "Organize the data from smallest to largest value."

What to turn in

Take a couple of screen captures of your document and post them. Await better instructions.

Content actions

Download module as:

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks