I am new to XSLT and having difficulty programming it. My work gave me an XML file and it must be transformed to look like an html file (in 2hours), using templates. It must also accept two global parameters, "description" (default value "yes") and "url" (default value "yes"), which will control whether or not the bookmark description and bookmark URL are displayed.
Can someone get me started on the right track or help me. I will donate money to your favorite charity. ~Jen Here is the code for all three files (xml source, html final output and the css stylesheet)
Here is the XML file
Here is the final output
Here is the css stylesheet.
Thanks again,
Jen
Can someone get me started on the right track or help me. I will donate money to your favorite charity. ~Jen Here is the code for all three files (xml source, html final output and the css stylesheet)
Here is the XML file
Code:
<?xml version="1.0"?>
<!DOCTYPE xbel PUBLIC "+//IDN python.org//DTD XML Bookmark Exchange Language 1.0//EN//XML" "[URL unfurl="true"]http://pyxml.sourceforge.net/topics/dtds/xbel-1.0.dtd">[/URL]
<xbel version="1.0">
<title>Some of David's Bookmarks</title>
<folder>
<title>Food</title>
<folder>
<title>Tea</title>
<bookmark href="[URL unfurl="true"]http://www.uptontea.com/">[/URL]
<title>Upton Tea Imports</title>
<desc>Purveyor of the world's finest teas.</desc>
</bookmark>
</folder>
<folder>
<title>Spices and Herbs</title>
<bookmark href="[URL unfurl="true"]http://www.penzeys.com/">[/URL]
<title>Penzeys Spices</title>
<desc>The best way to get your herbs and spices (both in terms of price, quality, and flavor). Their print catalog is wonderfully educational, and full of recipes.</desc>
</bookmark>
</folder>
<folder>
<title>Chips</title>
<bookmark href="[URL unfurl="true"]http://www.dirtys.com/">[/URL]
<title>Dirty Potato Chips</title>
<desc>My very favorite potato chips. Their motto is, "We don't wash out the natural potato flavor, so our chips are crunchier and tastier."</desc>
</bookmark>
<bookmark href="[URL unfurl="true"]http://www.artsandmarys.com/">[/URL]
<title>Art's and Mary's: Homestyle Tater Chips</title>
<desc>These are very good too. I usually get the "Dill Tater Chips", since dill chips are not commonly found.</desc>
</bookmark>
<bookmark href="[URL unfurl="true"]http://www.birdseyefoods.com/tims/">[/URL]
<title>Tim's Cascade Style Potato Chips</title>
<desc>My chip of choice when I'm in the Pacific Northwest (or whenever else I can find these in New England!). All are good -- especially the "Cracked Peppercorn"!</desc>
</bookmark>
<bookmark href="[URL unfurl="true"]http://www.capecodchips.com/">[/URL]
<title>Cape Cod Potato Chips</title>
<desc>Cape Code offers excellent chips made from different potato varieties (Dark Russet, Golden Russet and Yukon Gold). The "Firecracker Barbeque" chips don't last long when I'm around.</desc>
</bookmark>
</folder>
</folder>
<folder>
<title>HTTP Clients</title>
<bookmark href="[URL unfurl="true"]http://www.mozilla.com/firefox/">[/URL]
<title>Mozilla Firefox</title>
<desc>The award-winning, free Web browser is better than ever. Browse the Web with confidence - Firefox protects you from viruses, spyware and pop-ups. Enjoy improvements to performance, ease of use and privacy. It's easy to import your favorites and settings and get started. Download Firefox now and get the most out of the Web.</desc>
</bookmark>
<bookmark href="[URL unfurl="true"]http://browser.netscape.com/">[/URL]
<title>Netscape</title>
<desc>Netscape began by trying to make an Internet that users found easy to use. Today we offer integrations of intuitive digital tools, innovative attractions and infinite media content. The revolutionary new Netscape Browser 8.1 provides more security options, streamlines more standard browsing tasks and arms internet users with more timesaving solutions to their browsing needs.</desc>
</bookmark>
<bookmark href="[URL unfurl="true"]http://www.opera.com/">[/URL]
<title>Opera</title>
<desc>Opera is a high-quality Web browser available on a wide range of platforms. The Opera browser is a fast, full-featured, award-winning browser available for operating systems, including Windows, Linux and Mac OS.</desc>
</bookmark>
<bookmark href="[URL unfurl="true"]http://www.microsoft.com/ie/">[/URL]
<title>Microsoft Internet Explorer</title>
<desc>Download Internet Explorer 7 Beta 3, the latest version of Microsoft's new, improved, and free web browser.</desc>
</bookmark>
<bookmark href="[URL unfurl="true"]http://lynx.browser.org/">[/URL]
<title>Lynx</title>
<desc>Lynx is a fully-featured World Wide Web (WWW) client for users running cursor-addressable, character-cell display devices (e.g., vt100 terminals, vt100 emulators running on PCs or Macs, or any other character-cell display). It will display Hypertext Markup Language (HTML) documents containing links to files on the local system, as well as files on remote systems running http, gopher, ftp, wais, nntp, finger, or cso/ph/qi servers, and services accessible via logins to telnet, tn3270 or rlogin accounts. Current versions of Lynx run on Unix, VMS, Windows95/NT, 386DOS and OS/2 EMX.</desc>
</bookmark>
<bookmark href="[URL unfurl="true"]http://www.w3.org/Amaya/">[/URL]
<title>Amaya</title>
<desc>Amaya is a browser/authoring tool that allows you to publish documents on the Web. It is used to demonstrate and test many of the new developments in Web protocols and data formats. Given the very fast moving nature of Web technology, Amaya has a central role to play. It is versatile and extensible and is available on both Unix and Windows platforms.</desc>
</bookmark>
</folder>
<folder>
<title>Extensible Markup Language (XML)</title>
<bookmark href="[URL unfurl="true"]http://www.sciam.com/article.cfm?articleID=0008C786-91DB-1CD6-B4A8809EC588EEDF&ref=sciam">[/URL]
<title>Scientific American: Feature Article: XML and the Second Generation Web: May 1999</title>
<desc>The combination of hypertext and a global Internet started a revolution. A new ingredient, XML, is poised to finish the job. by Jon Bosak and Tim Bray</desc>
</bookmark>
<bookmark href="[URL unfurl="true"]http://www.sciam.com/article.cfm?articleID=00048144-10D2-1C70-84A9809EC588EF21&ref=sciam">[/URL]
<title>Scientific American: Feature Article: The Semantic Web: May 2001</title>
<desc>A new form of Web content that is meaningful to computers will unleash a revolution of new possibilities . by TIM BERNERS-LEE, JAMES HENDLER and ORA LASSILA</desc>
</bookmark>
<bookmark href="[URL unfurl="true"]http://www.w3.org/XML/1999/XML-in-10-points">[/URL]
<title>XML in 10 Points</title>
</bookmark>
<folder>
<title>RSS</title>
<bookmark href="[URL unfurl="true"]http://www.xml.com/pub/a/2002/12/18/dive-into-xml.html">[/URL]
<title>XML.com: What is RSS</title>
<desc>In Mark Pilgrim's inaugural Dive Into XML column, he reviews the history and technical details of the varieties of RSS on the Web. He also describes a method for parsing most active RSS feeds.</desc>
</bookmark>
<bookmark href="[URL unfurl="true"]http://www.webreference.com/authoring/languages/xml/rss/intro/">[/URL]
<title>Introduction to RSS - WebReference.com</title>
<desc>Rich Site Summary (RSS) is a lightweight XML format designed for sharing headlines and other Web content.</desc>
</bookmark>
</folder>
<folder>
<title>Extensible Stylesheet Language (XSL)</title>
<bookmark href="[URL unfurl="true"]http://xml.com/pub/a/2000/08/holman/index.html">[/URL]
<title>XML.com: What is XSLT?</title>
<desc>Part One of XML.com's series on the W3C's Extensible Stylesheet Language Transformation technology, written by XSLT instructor G. Ken Holman</desc>
</bookmark>
</folder>
</folder>
</xbel>
Here is the final output
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html>
<!--
Parameter "description" is set to no
Parameter "url" is set to -->
<head>
<!--
This comes from /xbel/title
-->
<title>Some of David's Bookmarks</title>
<link rel="stylesheet" type="text/css" href="xbel.css"/>
</head>
<body>
<!--
This comes from /xbel/title
-->
<h1>Some of David's Bookmarks</h1>
<ul>
<li>
<div class="folder-title">Food</div>
<ul>
<li>
<div class="folder-title">Tea</div>
<ul>
<li>
<div class="bookmark-title">
<a href="[URL unfurl="true"]http://www.uptontea.com/">Upton[/URL] Tea Imports</a>
</div>
<div class="bookmark-url">
<a href="[URL unfurl="true"]http://www.uptontea.com/"[/URL] title="Upton Tea Imports">[URL unfurl="true"]http://www.uptontea.com/</a>[/URL]
</div>
</li>
</ul>
</li>
<li>
<div class="folder-title">Spices and Herbs</div>
<ul>
<li>
<div class="bookmark-title">
<a href="[URL unfurl="true"]http://www.penzeys.com/">Penzeys[/URL] Spices</a>
</div>
<div class="bookmark-url">
<a href="[URL unfurl="true"]http://www.penzeys.com/"[/URL] title="Penzeys Spices">[URL unfurl="true"]http://www.penzeys.com/</a>[/URL]
</div>
</li>
</ul>
</li>
<li>
<div class="folder-title">Chips</div>
<ul>
<li>
<div class="bookmark-title">
<a href="[URL unfurl="true"]http://www.dirtys.com/">Dirty[/URL] Potato Chips</a>
</div>
<div class="bookmark-url">
<a href="[URL unfurl="true"]http://www.dirtys.com/"[/URL] title="Dirty Potato Chips">[URL unfurl="true"]http://www.dirtys.com/</a>[/URL]
</div>
</li>
<li>
<div class="bookmark-title">
<a href="[URL unfurl="true"]http://www.artsandmarys.com/">Art's[/URL] and Mary's: Homestyle Tater Chips</a>
</div>
<div class="bookmark-url">
<a href="[URL unfurl="true"]http://www.artsandmarys.com/"[/URL] title="Art's and Mary's: Homestyle Tater Chips">[URL unfurl="true"]http://www.artsandmarys.com/</a>[/URL]
</div>
</li>
<li>
<div class="bookmark-title">
<a href="[URL unfurl="true"]http://www.birdseyefoods.com/tims/">Tim's[/URL] Cascade Style Potato Chips</a>
</div>
<div class="bookmark-url">
<a href="[URL unfurl="true"]http://www.birdseyefoods.com/tims/"[/URL] title="Tim's Cascade Style Potato Chips">[URL unfurl="true"]http://www.birdseyefoods.com/tims/</a>[/URL]
</div>
</li>
<li>
<div class="bookmark-title">
<a href="[URL unfurl="true"]http://www.capecodchips.com/">Cape[/URL] Cod Potato Chips</a>
</div>
<div class="bookmark-url">
<a href="[URL unfurl="true"]http://www.capecodchips.com/"[/URL] title="Cape Cod Potato Chips">[URL unfurl="true"]http://www.capecodchips.com/</a>[/URL]
</div>
</li>
</ul>
</li>
</ul>
</li>
<li>
<div class="folder-title">HTTP Clients</div>
<ul>
<li>
<div class="bookmark-title">
<a href="[URL unfurl="true"]http://www.mozilla.com/firefox/">Mozilla[/URL] Firefox</a>
</div>
<div class="bookmark-url">
<a href="[URL unfurl="true"]http://www.mozilla.com/firefox/"[/URL] title="Mozilla Firefox">[URL unfurl="true"]http://www.mozilla.com/firefox/</a>[/URL]
</div>
</li>
<li>
<div class="bookmark-title">
<a href="[URL unfurl="true"]http://browser.netscape.com/">Netscape</a>[/URL]
</div>
<div class="bookmark-url">
<a href="[URL unfurl="true"]http://browser.netscape.com/"[/URL] title="Netscape">[URL unfurl="true"]http://browser.netscape.com/</a>[/URL]
</div>
</li>
<li>
<div class="bookmark-title">
<a href="[URL unfurl="true"]http://www.opera.com/">Opera</a>[/URL]
</div>
<div class="bookmark-url">
<a href="[URL unfurl="true"]http://www.opera.com/"[/URL] title="Opera">[URL unfurl="true"]http://www.opera.com/</a>[/URL]
</div>
</li>
<li>
<div class="bookmark-title">
<a href="[URL unfurl="true"]http://www.microsoft.com/ie/">Microsoft[/URL] Internet Explorer</a>
</div>
<div class="bookmark-url">
<a href="[URL unfurl="true"]http://www.microsoft.com/ie/"[/URL] title="Microsoft Internet Explorer">[URL unfurl="true"]http://www.microsoft.com/ie/</a>[/URL]
</div>
</li>
<li>
<div class="bookmark-title">
<a href="[URL unfurl="true"]http://lynx.browser.org/">Lynx</a>[/URL]
</div>
<div class="bookmark-url">
<a href="[URL unfurl="true"]http://lynx.browser.org/"[/URL] title="Lynx">[URL unfurl="true"]http://lynx.browser.org/</a>[/URL]
</div>
</li>
<li>
<div class="bookmark-title">
<a href="[URL unfurl="true"]http://www.w3.org/Amaya/">Amaya</a>[/URL]
</div>
<div class="bookmark-url">
<a href="[URL unfurl="true"]http://www.w3.org/Amaya/"[/URL] title="Amaya">[URL unfurl="true"]http://www.w3.org/Amaya/</a>[/URL]
</div>
</li>
</ul>
</li>
<li>
<div class="folder-title">Extensible Markup Language (XML)</div>
<ul>
<li>
<div class="bookmark-title">
<a href="[URL unfurl="true"]http://www.sciam.com/article.cfm?articleID=0008C786-91DB-1CD6-B4A8809EC588EEDF&ref=sciam">Scientific[/URL] American: Feature Article: XML and the Second Generation Web: May 1999</a>
</div>
<div class="bookmark-url">
<a href="[URL unfurl="true"]http://www.sciam.com/article.cfm?articleID=0008C786-91DB-1CD6-B4A8809EC588EEDF&ref=sciam"[/URL] title="Scientific American: Feature Article: XML and the Second Generation Web: May 1999">[URL unfurl="true"]http://www.sciam.com/article.cfm?articleID=0008C786-91DB-1CD6-B4A8809EC588EEDF&ref=sciam</a>[/URL]
</div>
</li>
<li>
<div class="bookmark-title">
<a href="[URL unfurl="true"]http://www.sciam.com/article.cfm?articleID=00048144-10D2-1C70-84A9809EC588EF21&ref=sciam">Scientific[/URL] American: Feature Article: The Semantic Web: May 2001</a>
</div>
<div class="bookmark-url">
<a href="[URL unfurl="true"]http://www.sciam.com/article.cfm?articleID=00048144-10D2-1C70-84A9809EC588EF21&ref=sciam"[/URL] title="Scientific American: Feature Article: The Semantic Web: May 2001">[URL unfurl="true"]http://www.sciam.com/article.cfm?articleID=00048144-10D2-1C70-84A9809EC588EF21&ref=sciam</a>[/URL]
</div>
</li>
<li>
<div class="bookmark-title">
<a href="[URL unfurl="true"]http://www.w3.org/XML/1999/XML-in-10-points">XML[/URL] in 10 Points</a>
</div>
<div class="bookmark-url">
<a href="[URL unfurl="true"]http://www.w3.org/XML/1999/XML-in-10-points"[/URL] title="XML in 10 Points">[URL unfurl="true"]http://www.w3.org/XML/1999/XML-in-10-points</a>[/URL]
</div>
</li>
<li>
<div class="folder-title">RSS</div>
<ul>
<li>
<div class="bookmark-title">
<a href="[URL unfurl="true"]http://www.xml.com/pub/a/2002/12/18/dive-into-xml.html">XML.com:[/URL] What is RSS</a>
</div>
<div class="bookmark-url">
<a href="[URL unfurl="true"]http://www.xml.com/pub/a/2002/12/18/dive-into-xml.html"[/URL] title="XML.com: What is RSS">[URL unfurl="true"]http://www.xml.com/pub/a/2002/12/18/dive-into-xml.html</a>[/URL]
</div>
</li>
<li>
<div class="bookmark-title">
<a href="[URL unfurl="true"]http://www.webreference.com/authoring/languages/xml/rss/intro/">Introduction[/URL] to RSS - WebReference.com</a>
</div>
<div class="bookmark-url">
<a href="[URL unfurl="true"]http://www.webreference.com/authoring/languages/xml/rss/intro/"[/URL] title="Introduction to RSS - WebReference.com">[URL unfurl="true"]http://www.webreference.com/authoring/languages/xml/rss/intro/</a>[/URL]
</div>
</li>
</ul>
</li>
<li>
<div class="folder-title">Extensible Stylesheet Language (XSL)</div>
<ul>
<li>
<div class="bookmark-title">
<a href="[URL unfurl="true"]http://xml.com/pub/a/2000/08/holman/index.html">XML.com:[/URL] What is XSLT?</a>
</div>
<div class="bookmark-url">
<a href="[URL unfurl="true"]http://xml.com/pub/a/2000/08/holman/index.html"[/URL] title="XML.com: What is XSLT?">[URL unfurl="true"]http://xml.com/pub/a/2000/08/holman/index.html</a>[/URL]
</div>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</body>
</html>
Here is the css stylesheet.
Code:
body { background-color: #ffffff; color: #000000;}
h1, h2, h3, h4, h5, h6 { text-align: center; color: #000000; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;}
a:link {color: blue; text-decoration: none}
a:visited {color: blue; text-decoration: none}
a:active {color: white; background: red; text-decoration: none}
a:hover {color: white; background: blue; text-decoration: none}
.folder-title { font-weight: bold; font-size: 1em; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;}
.bookmark-title {font-weight: bold; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;}
.bookmark-url {font-family: monospace;}
.bookmark-desc {margin: 0em 0em 0.5em 1em; }
Thanks again,
Jen