Jump to content

generating different html pages from the same xml and xsl files


Anch

Recommended Posts

Apologies in advance if this is the wrong forum - I'll put it in XSLT as well - and if my question is mind-bogglingly ignorant. I'm a student of website authoring and need help with my project. The idea is to create a style guide for a magazine using a single xml file, but break it into separate web pages for each letter of the alphabet. I don't want 26 xslt files, however - how can I tell the xslt to generate only the results for a specific letter? I've already set up the dtd with attributes for initials, and imagine I need to do something with URLs, but can't find out what or how...Many thanks in advance,Anch WarlowBirkbeck College, LondonHere's my xml code, with v basic data in it so far, and the xslt I've done so far with a very rough and unsuccessful attempt at solving the problem. Please be kind...

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE style SYSTEM "styleguide.dtd"><?xml-stylesheet type="text/xsl" href="REVstyleguide.xslt"?><style>    <entry position="copy" initial="c">        <heading>C</heading>        <subheading>Clichés</subheading>        <copy>blah blah</copy>    </entry>    <entry position="copy" initial="a">        <heading>A</heading>        <subheading>Acronyms</subheading>        <copy>blah blah</copy>      </entry>    <entry position="display" initial="a">        <heading></heading>        <subheading>Abronyms</subheading>        <copy>blah blah</copy>    </entry></style>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><?xslt version="1.0" encoding="UTF-8" ?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">					<xsl:variable name="initial"><!-- in here I want something that'll read the url for the initial-->		<script type="text/javascript">			document.write(location.hash);		</script></xsl:variable>	<xsl:template match="/">		<html  xmlns="http://www.w3.org/1999/xhtml">		<head>		<link rel="stylesheet" type="text/css" href="styleguide.css" />			<title>hello! magazine style guide</title>		</head>			<body class="wrapper">				<!-- start of page header -->				<div id="header">					<h1>magazine style guide</h1>				</div>				<!-- end of page header -->				<!-- start of primary nav bar -->				<ul id="navbar">  <!-- use list to create horizontal nav bars -->					<li><a href="index.htm" id="homebutton" title="to home page">Home</a> </li>					<li><a href="undercon.htm" id="intranetbutton" title="to iintranet home page">Intranet home</a></li>					<li><a href="" id="backissuesbutton" title="to back issues finder">Back issues finder</a></li>					<li><a href="" id="phonesbutton" title="to internal phone directory">Internal phone nos</a></li>				</ul>				<!-- end of primary navigation bar -->				<!-- main content  -->				<div id="middlecol">					<xsl:for-each select="style/entry[@position='copy'][@initial='$initial']">						<xsl:sort order="ascending"/>							<h1><xsl:value-of select="heading"/></h1>							<h3><xsl:value-of select="subheading"/></h3>							<p><xsl:value-of select="copy"/></p>					</xsl:for-each>				</div>								<div id="rightcol">						<xsl:for-each select="style/entry[@position='display'][@initial='$initial']">						<xsl:sort order="ascending"/>						<h1><xsl:value-of select="heading"/></h1>						<h3><xsl:value-of select="subheading"/></h3>						<p><xsl:value-of select="copy"/></p>					</xsl:for-each>				</div>				<!-- bottom nav bar -->				<!--this bit needs work to find out how to parse the attribute through the url-->				<ul id="bottomnav">					<li><a href="styleguide.xml?../entry/initial='a'" id="abutton" title="to a page">A</a></li>					<li><a href="styleguide.xml?initial=b" id="bbutton" title="to b page">B</a></li>					</ul>				<!-- end bottom nav bar -->				<!-- footer -->				<div id="footer">					© hello! magazine 					Last updated: 					<!-- #BeginDate format:Am1 -->October 28, 2008 <!-- #EndDate --> 					<a href="mailto:awarlow@hellomagazine.com">Contact</a>						</div>				<!-- end of footer -->				<!-- end of main content  -->							</body>				</html>	</xsl:template>	</xsl:stylesheet>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...