Try an online XSLT class for free!
Additional Resources

Tying It All Together: XSLT

In this lesson of the XML tutorial, you will learn...
  1. To apply the concepts you have learned thus far.

Tying it all Together

Exercise: Transforming the Business Letter

Duration: 60 to 90 minutes.

This exercise has two parts.

  1. First, you will transform the TyingItTogether/Exercises/BusinessLetter.xml to an HTML document. You can make it look however you like.
  2. Second, you will transform TyingItTogether/Exercises/BusinessLetter2.xml into XML that's valid against TyingItTogether/Exercises/BusinessLetter.dtd, so that you can then apply the XSLT you created in step 1 to output the transformed TyingItTogether/Exercises/BusinessLetter2.xml.

Code Sample: TyingItTogetherXsl/Exercises/BusinessLetter.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE BusinessLetter SYSTEM "BusinessLetter.dtd">
<?xml-stylesheet type="text/xsl" href="BusinessLetter.xsl"?>
<BusinessLetter>
 <Head>
  <SendDate>November 29, 2005</SendDate>
  <Recipient>
   <Name Title="Mr.">
    <FirstName>Joshua</FirstName>
    <LastName>Lockwood</LastName>
   </Name>
   <Company>Lockwood &amp; Lockwood</Company>
   <Address>
    <Street>291 Broadway Ave.</Street>
    <City>New York</City>
    <State>NY</State>
    <Zip>10007</Zip>
    <Country>United States</Country>
   </Address>
  </Recipient>
 </Head>
 <Body>
  <List>
   <Heading>
    Along with this letter, I have enclosed the following items:
   </Heading>
   <ListItem>two original, execution copies of the Webucator 
    Master Services Agreement</ListItem>
   <ListItem>two original, execution copies of the Webucator 
    Premier Support for Developers Services Description between 
    Lockwood &amp; Lockwood and Webucator, Inc.</ListItem>
  </List>
  <Para>Please sign and return all four original, execution copies to
   me at your earliest convenience.  Upon receipt of the executed copies, 
   we will immediately return a fully executed, original copy of both 
   agreements to you.</Para>
  <Para>Please send all four original execution copies to my attention as follows:
   <Person>
    <Name>
     <FirstName>Bill </FirstName>
     <LastName>Smith</LastName>
    </Name>
    <Address>
     <Company>Webucator, Inc.</Company>
     <Street>4933 Jamesville Rd.</Street>
     <City>Jamesville</City>
     <State>NY</State>
     <Zip>13078</Zip>
     <Country>USA</Country>
    </Address>
   </Person>
  </Para>
  <Para>If you have any questions, feel free to call me at 
   <Phone>800-555-1000 x123</Phone> or e-mail me at 
   <Email>bsmith@webucator.com</Email>.</Para>
 </Body>
 <Foot>
  <Closing>
   <Name>
    <FirstName>Bill </FirstName>
    <LastName>Smith</LastName>
   </Name>
   <JobTitle>VP, Operations</JobTitle>
  </Closing>
 </Foot>
</BusinessLetter>

Code Sample: TyingItTogetherXsl/Exercises/BusinessLetter2.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Letter2Letter.xsl"?>
<Letter>
 <Date>November 29, 2005</Date>
 <To>
  <Name>
   <Title>Mr.</Title>
   <FName>Joshua</FName>
   <LName>Lockwood</LName>
  </Name>
  <Company>Lockwood &amp; Lockwood</Company>
  <Address>
   <Street>291 Broadway Ave.</Street>
   <City>New York</City>
   <State>NY</State>
   <Zip>10007</Zip>
   <Country>United States</Country>
  </Address>
 </To>
 <List>
  <ListHead>
   Along with this letter, I have enclosed the following items:
  </ListHead>
  <LI>two original, execution copies of the Webucator Master 
   Services Agreement</LI>
  <LI>two original, execution copies of the Webucator Premier 
   Support for Developers Services Description between Lockwood 
    &amp; Lockwood and Webucator, Inc.</LI>
 </List>
 <P>Please sign and return all four original, execution copies to me at 
  your earliest convenience.  Upon receipt of the executed copies, we 
  will immediately return a fully executed, original copy of both 
  agreements to you.</P>
 <P>Please send all four original, execution copies to my attention as 
  follows:
   <Person>
   <Name>
    <FName>Bill </FName>
    <LName>Smith</LName>
   </Name>
   <Address>
    <Company>Webucator, Inc.</Company>
    <Street>4933 Jamesville Rd.</Street>
    <City>Jamesville</City>
    <State>NY</State>
    <Zip>13078</Zip>
    <Country>USA</Country>
   </Address>
  </Person>
 </P>
 <P>If you have any questions, feel free to call me at 
  <Phone>800-555-1000 x123</Phone> or e-mail me at 
  <Email>bsmith@webucator.com</Email>.</P>
 <End>
  <Name>
   <FName>Bill </FName>
   <LName>Smith</LName>
  </Name>
  <Title>VP, Operations</Title>
 </End>
</Letter>

Code Sample: TyingItTogetherXsl/Exercises/BusinessLetter.dtd

<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT Address (Company?, Street, City, State, Zip, Country)>
<!ELEMENT Body (List, Para+)>
<!ELEMENT BusinessLetter (Head, Body, Foot)>
<!ELEMENT City (#PCDATA)>
<!ELEMENT Closing (Name, JobTitle)>
<!ELEMENT Company (#PCDATA)>
<!ELEMENT Country (#PCDATA)>
<!ELEMENT Email (#PCDATA)>
<!ELEMENT FirstName (#PCDATA)>
<!ELEMENT Foot (Closing)>
<!ELEMENT Head (SendDate, Recipient)>
<!ELEMENT Heading (#PCDATA)>
<!ELEMENT JobTitle (#PCDATA)>
<!ELEMENT LastName (#PCDATA)>
<!ELEMENT List (Heading, ListItem+)>
<!ELEMENT ListItem (#PCDATA)>
<!ELEMENT Name (FirstName, LastName)>
<!ATTLIST Name
 Title CDATA #IMPLIED
>
<!ELEMENT Para (#PCDATA | Person | Email | Phone)*>
<!ELEMENT Person (Name, Address)>
<!ELEMENT Phone (#PCDATA)>
<!ELEMENT Recipient (Name, Company, Address)>
<!ELEMENT SendDate (#PCDATA)>
<!ELEMENT State (#PCDATA)>
<!ELEMENT Street (#PCDATA)>
<!ELEMENT Zip (#PCDATA)>

Tying It All Together: XSLT Conclusion

Congratulations! You have come a long way.

To continue to learn XML go to the top of this page and click on the next lesson in this XML Tutorial's Table of Contents.

Use of http://www.learn-xslt-tutorial.com (Website) implies agreement to the following:

Copyright Information

All pages and graphics on Website are the property of Webucator, Inc. unless otherwise specified.

None of the content on Website may be redistributed or reproduced in any way, shape, or form without written permission from Webucator, Inc.

No Printing or saving of pages or content on Website

This content may not be printed or saved. It is for online use only.


Linking to Website

You may link to any of the pages on Website; however, you may not include the content in a frame or iframe without written permission from Webucator, Inc.


Warranties

Website is provided without warranty of any kind. There are no guarantees that use of the site will not be subject to interruptions. All direct or indirect risk related to use of the site is borne entirely by the user. All code and explanations provided on this site are provided without warranties to correctness, performance, fitness, merchantability, and/or any other warranty (whether expressed or implied).


For individual private use only

You agree not to use this online manual to deliver or receive training. If you are delivering or attending a class that is making use of this online manual, you are in violation of our terms of service. Please report any abuse to courseware@webucator.com. If you would like to deliver or receive training using this manual, please fill out the form at http://www.webucator.com/Contact.cfm