Assignment 4 - due on 02/22 [xhtml]

Download the netbeans project for this assignment and answer the following questions:

  1. SOAP is an envelope format from the W3C for messaging. It has the basic structure of a root 'Envelope' element that can contain a 'Header' and 'Body' element (in that order). The namespace is "http://www.w3.org/2003/05/soap-envelope". For example:

    <e:Envelope xmlns:e='http://www.w3.org/2003/05/soap-envelope'>
    <e:Header><to>me</to></e:Header>
    <e:Body><message>Happy Birthday</message></e:Body>
    </e:Envelope>

    Create a transformation that wraps the message-1.xml, message-2.xml, and message-3.xml documents in the project with a SOAP envelope. The elements within the 'to', 'from', and 'subject' should be copied into the 'Header' element and the rest should be placed in the body in the document order. If the header elements are contained by ancestor elements (e.g. their own 'Header' element), do not copy those elements.

  2. Assume we're in a document structured as follows:

    <lecture><title>My Lecture</title>
    <slide><title>...</title>
    <contents>...</contents>
    </slide>
    <slide><title>...</title>
    <contents>...</contents>
    </slide>
    ...
    </lecture>

    Assume the context is 'slide/contents'--that is, the 'content's element of any slide. For each of the sentences in the list below, write an XPath expressions that selects the content described. Write the XPath as an expression you might use in a select expression of xsl:apply-templates:

    • The previous 'slide' in document order (i.e. the previous sibling of the current 'slide' element).

    • The set of 'term' elements on this slide that have a 'term-definition' element somewhere in the document--not necessarily on the current slide being processed--where the 'id' attribute of 'term-definition' matches the 'ref' attribute of 'term'. That is, find all term elements that have matching term-definition elements.

    There is an example document called slide.xml in the project.

  3. Create a transformation that does the following:

    • For each 'date' attribute, re-format the date from the format YYYY-MM-DD to M/D/YYYY. For example, "2005-02-09" gets reformatted as "9/2/2004".

    • For each 'price' element, re-format the number contents as a monitary amount prefixed with a currency symbol. For example, for US, re-format 10 as $10.00 and for european countries, re-format as €10.00. The euro-sign is &#x20ac; as a character reference. Each price element will have an xml:lang attribute with the country code. For this assignment, assume 'us' for the United States, 'fr' for France, 'de' for Germany.

    There are two example documents date-and-price.xml and date-and-price-2.xml in the project.

[syllabus]