Date: Fri, 3 Aug 2001 07:33:09 +0100 From: Nik Clayton <nik@freebsd.org> To: Nik Clayton <nik@freebsd.org> Cc: doc@freebsd.org Subject: Re: Depending on libxslt Message-ID: <20010803073308.A33872@canyon.nothing-going-on.org> In-Reply-To: <20010802171857.B24850@canyon.nothing-going-on.org>; from nik@freebsd.org on Thu, Aug 02, 2001 at 05:18:57PM %2B0100 References: <20010802171857.B24850@canyon.nothing-going-on.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--cmJC7u66zC7hs+87 Content-Type: multipart/mixed; boundary="HlL+5n6rz5pIUxbD" Content-Disposition: inline --HlL+5n6rz5pIUxbD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Aug 02, 2001 at 05:18:57PM +0100, Nik Clayton wrote: > 2. The newsflash announcements can become an XML document. It's then > pretty trivial to generate the newsflash HTML page automatically. > It's also even more trivial to generate an RDF file -- this is the > format used by news 'syndication' sites to share headlines and > links, so that it'll be easy to get FreeBSD news headlines on > sites like DaemonNews and Slashdot. For an example of what I'm talking about, attached is a little something I've knocked up on the flight back to the UK. It shows how we'd probably go about implementing this sort of thing. First, make sure that you have installed libsxlt from the ports collection. Then save the attached news.xsl and news.xml files somewhere. news.xsl is the stylesheet, news.xml is the data. If you take a look at news.xml you'll see that it's very simple markup. Everything is contained inside a <news> element, which then has sub-elements for <month>s. Each month has a <name>, and contains <event>s. Each event has a <date>, and one or more <p> elements, which may contain <a> elements. The <p> and <a> elements are directly analogous to HTML. news.xsl is the stylesheet. It's a bit big, but don't be put off. The first 100 or so lines of news.xsl would normally be kept in a separate file, and shared amongst all the stylesheets, in the same way that we have various includes.sgml files kicking around the www/ tree. I haven't done that for this example because I'm still finding my way around XSL. =20 If you look at these lines you'll see lots of <xsl:variable> declarations. = =20 I'm using these instead of the entities we use in the SGML version because= =20 XSL doesn't make it very easy to create new entities on the fly. You can= =20 also do neat things with XSL variables. The section that starts=20 <xsl:template match=3D"news"> ... </xsl:template> Is the meat of the stylesheet. This sets up the body of the HTML page, includes the headers, footers, and introductory text, and starts the processing of the data in news.xml. Notice how the stylesheet contains a mixture of XSL markup (every element that starts <xsl:...>, and the HTML that we're going to output. Also notice how you can refer to variables in attribute lists. All the other <xsl:template match=3D"..."> elements contain the code that converts subtrees of the document into HTML. If you're familiar with the DSSSL stylesheets then <xsl:template match=3D"foo"> ... </xsl:template> is roughly equivalent to (element foo ... ) These templates are all called by the <xsl:apply-templates/> element in the main template. You can then convert news.xml to HTML by running=20 xsltproc news.xsl news.xml > news.html and then load news.html in to your browser. This works best if you run it inside the www/en/news/ directory in a checked out copy of the website, because then the images will be found as well -- that's not an absolute requirement though if you just want to see what this looks like. This isn't quite a finished solution. Apart from the fact that the first 100 or so lines need to split out in to separate files, the format of news.xml needs rethinking slightly. For example, if we were to syndicate this content in to an RDF file we really want separate headlines for the RDF. So perhaps: <event> <date>17-Jun-2001</date> <headline>FreeBSD PowerPC reaches "mount root" milestone</headline> <p>Benno Rice has completed enough work to allow FreeBSD to reach the mountroot prompt on the PowerPC processor. Please see the PowerPC platform page and mailing list for more information.</p> </event> The <headline> doesn't necessarily need to be included in the HTML output (although it could be). Maybe we should store the dates in an ISO format (<date>20010617</date> ?)= =20 and let the XSL stylesheets convert that back in to something a bit more useful. Perhaps we want different classes of event: <event class=3D"new-committer"> <event class=3D"security-advisory"> <event class=3D"misc"> Any recommendations? If anyone knows of any standards for marking up 'news stories' or things like this then now would be a good time to say so :-) N --=20 FreeBSD: The Power to Serve http://www.freebsd.org/ FreeBSD Documentation Project http://www.freebsd.org/docproj/ --- 15B8 3FFC DDB4 34B0 AA5F 94B7 93A8 0764 2C37 E375 --- --HlL+5n6rz5pIUxbD Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="news.xsl" Content-Transfer-Encoding: quoted-printable <?xml version=3D"1.0" encoding=3D"ISO-8859-1" ?> <xsl:stylesheet xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform" version= =3D"1.0"> <!-- Variables that must be set on a per-document basis --> <xsl:variable name=3D"base" select=3D"'..'"/> <xsl:variable name=3D"title" select=3D"'FreeBSD News Flash'"/> =20 <!-- Variables based on entities in www/en/includes.sgml. Ordinarily=20 these would be stored in www/en/includes.xsl --> <xsl:variable name=3D"i.daemon"> <img src=3D"{$base}/gifs/daemon.gif" alt=3D"" align=3D"left" width=3D"8= 0" height=3D"76"/> </xsl:variable> <xsl:variable name=3D"i.new"> <img src=3D"{$base}/gifs/new.gif" alt=3D"[New!]" width=3D"28" height=3D= "11"/> </xsl:variable> <xsl:variable name=3D"copyright" select=3D"'Copyright (c) 1995-2001 the F= reeBSD Project. All rights reserved.'"/> <xsl:variable name=3D"email" select=3D"'freebsd-questions'"/> <xsl:variable name=3D"author"> <a href=3D"{$base}/mailto.html"><xsl:value-of select=3D"$email"/>@FreeB= SD.org</a><br/><xsl:value-of select=3D"$copyright"/> </xsl:variable> <xsl:variable name=3D"date" select=3D"''"/> <xsl:variable name=3D"home"> <a href=3D"{$base}/index.html"><img src=3D"{$base}/gifs/home.gif" alt= =3D"FreeBSD Home Page" border=3D"0" align=3D"right" width=3D"101" height=3D= "33"/></a> </xsl:variable> <xsl:variable name=3D"header1"> <head> <title><xsl:value-of select=3D"$title"/></title> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DISO= -8859-1"/> <meta name=3D"MSSmartTagsPreventParsing" content=3D"TRUE"/> </head> </xsl:variable> <xsl:attribute-set name=3D"att.body"> <xsl:attribute name=3D"text">#000000</xsl:attribute> <xsl:attribute name=3D"bgcolor">#FFFFFF</xsl:attribute> <xsl:attribute name=3D"alink">#FFCC33</xsl:attribute> </xsl:attribute-set> <xsl:variable name=3D"header2"> <img src=3D"{$base}/gifs/bar.gif" alt=3D"Navigation Bar" width=3D"565"= =20 height=3D"33" border=3D"0" usemap=3D"#bar"/> =20 <h1 align=3D"left"><font color=3D"#660000"><xsl:value-of select=3D"$tit= le"/></font></h1> <br clear=3D"all"/> <map name=3D"bar"> <area shape=3D"rect" coords=3D"1,1,111,31"=20 href=3D"{$base}/index.html" alt=3D"Top"/> <area shape=3D"rect" coords=3D"112,11,196,31"=20 href=3D"{$base}/ports/index.html" alt=3D"Applications"/> <area shape=3D"rect" coords=3D"196,12,257,33"=20 href=3D"{$base}/support.html" alt=3D"Support"/> <area shape=3D"rect" coords=3D"256,12,365,33"=20 href=3D"{$base}/docs.html" alt=3D"Documentation"/>=20 <area shape=3D"rect" coords=3D"366,13,424,32"=20 href=3D"{$base}/commercial/commercial.html" alt=3D"Vendors"/> <area shape=3D"rect" coords=3D"425,16,475,32"=20 href=3D"{$base}/search/search.html" alt=3D"Search"/> <area shape=3D"rect" coords=3D"477,16,516,33"=20 href=3D"{$base}/search/index-site.html" alt=3D"Index"/> <area shape=3D"rect" coords=3D"516,15,562,33"=20 href=3D"{$base}/index.html" alt=3D"Top"/> <area shape=3D"rect" coords=3D"0,0,564,32"=20 href=3D"{$base}/index.html" alt=3D"Top"/> </map> </xsl:variable> <xsl:variable name=3D"footer"> <hr noshade=3D"noshade"/> <address><xsl:copy-of select=3D"$author"/><br/> <xsl:copy-of select=3D"$date"/></address> </xsl:variable> =20 <xsl:variable name=3D"rel.current" select=3D"4.3"/> <xsl:variable name=3D"u.rel.notes" select=3D"'{$base}/releases/{$rel.curr= ent}R/notes.html'"/> <xsl:variable name=3D"u.rel.announce" select=3D"'{$base}/releases/{$rel.c= urrent}R/announce.html'"/> <xsl:variable name=3D"u.rel.errata" select=3D"'{$base}/releases/{$rel.cur= rent}R/errata.html'"/> =20 <!-- Variables based on entities from www/en/news/includes.sgml. =20 Ordinarily these would be stored in www/en/news/includes.xsl --> <xsl:variable name=3D"newshome"> <a href=3D"news.html">News Home</a> </xsl:variable> <!-- The generated HTML page begins here --> <xsl:template match=3D"news"> <html> =20 <xsl:copy-of select=3D"$header1"/> <body xsl:use-attribute-sets=3D"att.body"> <xsl:copy-of select=3D"$header2"/> <!-- Notice how entity references in SGML become variable references in the stylesheet, and that the syntax for referring to variables inside an attribute is "{$variable}". This is just dis-similar enough to Perl and the shell that you end up writing ${variable} all the time, and then scratch your=20 head wondering why the stylesheet isn't working.--> <!-- Also notice that because this is now XML and not SGML, empty elements, like IMG, must have a trailing "/" just inside the= =20 closing angle bracket, like this " ... />" --> <img src=3D"{$base}/gifs/news.jpg" align=3D"right" border=3D"0" width=3D"1= 93" height=3D"144" alt=3D"FreeBSD News"/> <p>FreeBSD is a rapidly developing operating system. Keeping up on the latest developments can be a chore! To keep on top of things, be sure and check this page periodically. Also, you may wish to subscribe to the=20 <a href=3D"{$base}/handbook/eresources.html#ERESOURCES-MAIL">freebsd-ann= ounce mailing list</a>.</p> <p>For latest news of FreeBSD Java Project please visit=20 <a href=3D"{$base}/java/newsflash.html">FreeBSD/Java NewsFlash</a> page.</p> =20 <p>For a detailed description of past, present, and future releases, see the <strong><a href=3D"{$base}/releases/index.html">Release Information</a></strong> page.</p> =09 <p>For FreeBSD Security Advisories, please refer to the=20 <a href=3D"{$base}/security/#adv">Security Information</a> page.</p> =09 <xsl:apply-templates/> =09 <p>Older announcements: <a href=3D"2000/index.html">2000</a>, <a href=3D"1999/index.html">1999</a>, <a href=3D"1998/index.html">1998</a>, <a href=3D"1997/index.html">1997</a>, <a href=3D"1996/index.html">1996</a></p> =09 <xsl:copy-of select=3D"$newshome"/> <xsl:copy-of select=3D"$footer"/> </body> </html> </xsl:template> <!-- Everything that follows are templates for the rest of the content --> <xsl:template match=3D"month"> <h1><xsl:value-of select=3D"name"/></h1> <ul> <xsl:apply-templates/> </ul> </xsl:template> <xsl:template match=3D"name"/> <!-- Deliberately left blank --> =20 <xsl:template match=3D"event"> <li><p><b><xsl:value-of select=3D"date"/>:</b><xsl:text> </xsl:text> <xsl:apply-templates/> </p></li> </xsl:template> <xsl:template match=3D"date"/> <!-- Deliberately left blank --> <!-- When the href attribute contains a '$base', expand it to the current value of the $base variable. --> <!-- All your $base are belong to us. Ho ho ho --> <xsl:template match=3D"a"> <a><xsl:attribute name=3D"href"> <xsl:choose> <xsl:when test=3D"contains(@href, '$base')"> <xsl:value-of select=3D"concat(substring-before(@href, '$base'), $base= , substring-after(@href, '$base'))"/> </xsl:when> <xsl:otherwise> <xsl:value-of select=3D"@href"/> </xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:apply-templates/> </a> </xsl:template> </xsl:stylesheet> --HlL+5n6rz5pIUxbD Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="news.xml" Content-Transfer-Encoding: quoted-printable <news> <month> <name>June 2001</name> <event> <date>21-Jun-2001</date> =09 <p>New committer: <a href=3D"mailto:brooks@FreeBSD.org">Brooks Davis<= /a> (Networking, Mobile Computing)</p></event> <event> <date>20-Jun-2001</date> =20 <p><a href=3D"mailto:john@kozubik.com">John Kozubik</a> has submitted= =20 an article explaining=20 <a href=3D"$base/doc/en_US.ISO8859-1/articles/solid-state/index.html">How to use FreeBSD with solid state media</a>.</p> </event> <event> <date>17-Jun-2001</date> =09 <p><a href=3D"mailto:benno@FreeBSD.org">Benno Rice</a> has completed = enough work to allow FreeBSD to reach the mountroot prompt on the PowerPC processor. Please see the PowerPC platform=20 <a href=3D"$base/platforms/ppc.html">page</a> and mailing list for more information.</p> </event> <event> <date>15-Jun-2001</date> <p>New committer: <a href=3D"mailto:silby@FreeBSD.org">Mike Silbersac= k</a> (Networking)</p> </event> <event><date>14-Jun-2001</date> <p>New committer: <a href=3D"mailto:wjv@FreeBSD.org">Johann Visagie</= a> (Ports)</p> </event> <event><date>13-Jun-2001</date> <p><a href=3D"mailto:rwatson@FreeBSD.org">Robert Watson</a> has compi= led a=20 <a href=3D"http://docs.freebsd.org/cgi/getmsg.cgi?fetch=3D481962+0+archive= /2001/freebsd-hackers/20010617.freebsd-hackers">status report</a> for the FreeBSD Project. These reports are scheduled to continue on a monthly basis.</p> </event> <event><date>11-Jun-2001</date> <p>New committer: <a href=3D"mailto:tobez@FreeBSD.org">Anton Berezin<= /a> (all things Perl)</p> </event> <event><date>06-Jun-2001</date> <p>New committer: <a href=3D"mailto:dwcjr@FreeBSD.org">David W. Chapm= an Jr. </a>(Ports)</p> </event> <event><date>06-Jun-2001</date> <p>New committer: <a href=3D"mailto:markp@FreeBSD.org">Mark Pulford</= a> (Ports)</p> </event> <event><date>01-Jun-2001</date> <p>New committer: <a href=3D"mailto:cjc@FreeBSD.org">Crist J. Clark</= a> (Networking, security)</p> </event> </month> <month> <name>May 2001</name> <event> <date>24-May-2001</date> =20 <p>The famous ftp site, <a href=3D"ftp://ftp.FreeBSD.org/">ftp.FreeBSD.org</a>, is now back= in=20 full operation. Many thanks to=20 <a href=3D"http://www.teledanmark.com/english/menu/start.htm">Tele= =20 Danmark</a>, who are supplying the machine as well as the network connection.</p> </event> <event> <date>16-May-2001</date> =20 <p>New committer: <a href=3D"mailto:pirzyk@FreeBSD.org">Jim Pirzyk</a= ></p> </event> <event> <date>02-May-2001</date> =20 <p>The first May 2001 issue of the=20 <a href=3D"http://www.freebsdzine.org/">FreeBSD 'zine</a> is now available. Starting this month, there will be two issues per month; one on the 1st, and one on the 15th.</p> </event> </month> <month> <name>April 2001</name> <event> <date>27-Apr-2001</date> =20 <p>FreeBSD now works with multiple processors on Alpha systems, thank= s to the efforts of <a href=3D"mailto:jhb@FreeBSD.org">John Baldwin</a>, <a href=3D"mailto:gallatin@FreeBSD.org">Andrew Gallatin</a>, and <a href=3D"mailto:dfr@FreeBSD.org">Doug Rabson</a>.</p> </event> <event> <date>25-Apr-2001</date> =20 <p>New committer: <a href=3D"mailto:tshiozak@FreeBSD.org">Takuya=20 SHIOZAKI</a> (Internationalization)</p> </event> <event> <date>25-Apr-2001</date> =20 <p>New committer: <a href=3D"mailto:ue@FreeBSD.org">Udo Erdelhoff</a>= =20 (Docs)</p> </event> <event> <date>18-Apr-2001</date> =09 <p>The=20 <a href=3D"$base/doc/en_US.ISO8859-1/books/developers-handbook/index.html"= >Developer's Handbook</a> is now available on the web site. This is an evolving resource for people wanting to develop software for FreeBSD (and not just for the committers who are developing FreeBSD). Don't forget that a <a href=3D"$base/docs.html">complete list of documentation</a> available from this site is also available.</p> </event> <event> <date>17-Apr-2001</date> =20 <p>Addison Wesley have allowed us to republish=20 <a href=3D"$base/doc/en_US.ISO8859-1/books/corp-net-guide/index.html">Chap= ter 8</a> of the=20 <a href=3D"http://cseng.aw.com/book/0,,0201704811,00.html">FreeBSD Corporate Networker's Guide</a>. Chapter 8 provides an in-depth look at providing printing services to Windows, NT, and Novell clients using FreeBSD.</p> </event> <event> <date>16-Apr-2001</date> =09 <p>Yet another new committer: <a href=3D"mailto:schweikh@FreeBSD.org"= >Jens Schweikhardt</a> (Standards compliance)</p> </event> <event> <date>12-Apr-2001</date> =09 <p>The April issue of <a href=3D"http://www.freebsdzine.org/">The FreeBSD 'zine</a> is now available.</p> </event> <event> <date>10-Apr-2001</date> =09 <p>The <a href=3D"&base;/ports/index.html">Ports Collection</a> n= ow contains more than 5,000 individual entries!</p> </event> <event> <date>05-Apr-2001</date> =09 <p>New committer: <a href=3D"mailto:greid@FreeBSD.org">George Reid</a> (Sound support, ports)</p> </event> <event> <date>04-Apr-2001</date> =20 <p>Wind River to Acquire BSDi Software Assets. Please read the=20 <a href=3D"http://www.windriver.com/press/html/bsdi.html">Wind River Press Release</a>, the announcement from=20 <a href=3D"http://www.freebsd.org/cgi/mid.cgi?20010404220529.E3AFE37B727">= Jordan K. Hubbard</a>, and the=20 <a href=3D"http://www.freebsd.org/cgi/mid.cgi?Pine.NEB.3.96L.1010405211037= .46990E-100000">FreeBSD Core Team statement</a>.</p> </event> </month> <month> <name>March 2001</name> <event> <date>25-Mar-2001</date> =09 <p>New committer: <a href=3D"mailto:yar@FreeBSD.org">Yar Tikhiy</a> (Networking)</p> </event> <event> <date>24-Mar-2001</date> =20 <p>New committer: <a href=3D"mailto:eric@FreeBSD.org">Eric Melville</= a> (System tools)</p> </event> <event> <date>13-Mar-2001</date> =20 <p>The March issue of <a href=3D"http://www.freebsdzine.org/">The FreeBSD 'zine</a> is now available.</p> </event> <event> <date>09-Mar-2001</date> =09 <p>New committer: <a href=3D"mailto:dd@FreeBSD.org">Dima Dorfman</a> (Docs)</p> </event> <event> <date>07-Mar-2001</date> =09 <p>New committer: <a href=3D"mailto:keichii@FreeBSD.org">Michael C. W= u</a> (Internationalization, porting efforts)</p> </event> <event> <date>06-Mar-2001</date> =20 <p>New committer: <a href=3D"mailto:tmm@FreeBSD.org">Thomas=20 M&ouml;stl</a> (POSIX.1e extensions)</p>=20 </event> <event> <date>06-Mar-2001</date> =09 <p>New committer: <a href=3D"mailto:orion@FreeBSD.org">Orion Hodson</= a> (Sound support)</p> </event> </month> <month> <name>February 2001</name> <event> <date>20-Feb-2001</date> =20 <p>New committer: <a href=3D"mailto:jesper@FreeBSD.org">Jesper Skriver</a></p> </event> <event> <date>16-Feb-2001</date> =20 <p>The February issue of <a href=3D"http://www.freebsdzine.org/">The FreeBSD 'zine</a> is now available.</p> </event> <event> <date>05-Feb-2001</date> =09 <p>New committer: <a href=3D"mailto:mikeh@FreeBSD.org">Mike Heffner</= a> (Audit project)</p> </event> </month> <month> <name>January 2001</name> <event> <date>24-Jan-2001</date> =20 <p>New committer: <a href=3D"mailto:olgeni@FreeBSD.org">Jimmy Olgeni<= /a> (Ports)</p> </event> <event> <date>23-Jan-2001</date> =09 <p>New committer: <a href=3D"mailto:dinoex@FreeBSD.org">Dirk Meyer</a> (Ports)</p> </event> <event> <date>20-Jan-2001</date> =09 <p>New committer: <a href=3D"mailto:ijliao@FreeBSD.org">Ying-chieh Li= ao</a> (Ports)</p> </event> </month> </news> --HlL+5n6rz5pIUxbD-- --cmJC7u66zC7hs+87 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: For info see http://www.gnupg.org iEYEARECAAYFAjtqRaMACgkQk6gHZCw343XAFwCeKsgTNsScdXvqrG/t4DiSWdpq dxMAnAgGa8+jp3BQYnp88lj+0S9cZhx/ =FzxI -----END PGP SIGNATURE----- --cmJC7u66zC7hs+87-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-doc" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010803073308.A33872>