Subject: Re: [xsl] Transforming into embedded HTML From: Micky Allen <fisi@xxxxxxxxxxxxxxxx> Date: Mon, 08 Jun 1987 00:37:02 +0100 |
Hi there Joe I know this has been covered already, but I have a similar requirement where I convert an XML jobs listing into "html" and then publish it on my website <www.contaminatedLand.co.uk/jobs-car/titl-job.htm> where it is displayed as an alphabetical listing (by Title) A typical listing is as follows (emp=Employer, tit=Title, loc=Location exp=Experience, dat=Date of Publication, sor=Source, web=Website mai=Email address, sal=Salary) where <may-d> is the 4th week in May ------------------------------------------------ <XML code> --------------------------------- <?xml version="1.0" encoding="ISO8859-1"?> <!DOCTYPE dec-a[ <?xml-stylesheet type="text/xsl" href="to-tit3.xsl"?>]> <may-d> <job tit="Contaminated Land Consultant" loc="Northwest" exp="(8 yrs)" emp="Allen + York" web="www.ifi.co.uk/jobs.phtml?jobid=2317" dat="may-21" sor="EBM" /> <job tit="Hydrogeologist" web="www.ends.co.uk/registrants/jobs/jobdata/200205215400.htm" sal="£ 30 k" loc="Nottingham" emp="BBT" sor="ENDS" dat="may-21" /> <job tit="Planning + Liaison Officer" emp="Isle of Wight C" loc="Isle of Wight" sal="£ 19-21 k" exp="(1 yr)" mai="aonb@xxxxxxxxxx" dat="may-22" sor="Guardian" /> <job tit="Principal Consultant" loc="Southwest" exp="(10-15 yrs)" emp="Evergreen Resources" web="www.ifi.co.uk/jobs.phtml?jobid=2319" dat="may-21" sor="EBM" /> <job tit="Press Officer" emp="Interpol" loc="Lyon" mai="staff@xxxxxxxxxxxx" web="www.interpol.int" dat="may-25" sor="Economist" /> </may-d> ------------------------------------------- </XML code> ----------------------------- My main requirement is to utilise a website address if possible rather than an email address (firstly to cut down on spammers "hoovering-up" the email address, and secondly to build a set of outgoing links to feed Google's appetite <grin>) The XSL code is as follows (bear in mind that I am a newbie, and by profession am a geologist - motto "if in doubt hit it repeatedly with a hammer, and then pour hydrochloric acid over it to see if it fizzes", i.e. my computing skills are a bit limited due to low boredom threshold !) Oh yes the other constraint is that I use MSIE to run the XML/XSL transformation (sorry......) ---------------------------------------------< XSL code >----------------------------------------- <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <output method="html" /> <xsl:template match="/"> <!-- Simple list --> <html> <body> <html> <ol> <ol> <xsl:for-each order-by="@tit" select="may-d/job"> <xsl:for-each order-by="@emp" /> <!-- for websites --> <li> <xsl:choose> <xsl:when test="@web"> <li> <A HREF="http://<xsl:value-of select="@web"/>"><!-- title --><xsl:value-of select="@tit"/></A>, <xsl:value-of select="@emp"/>, <xsl:value-of select="@loc"/>, <xsl:value-of select="@sal"/> <xsl:value-of select="@exp"/>, <xsl:value-of select="@sor"/> </li> </xsl:when> <!-- /xsl:for-each --> <!-- for emails --> <xsl:otherwise> <li> <A HREF="mailto:<xsl:value-of select="@mai"/>"><!-- title --><i><xsl:value-of select="@tit"/></i></A>, <xsl:value-of select="@emp"/>, <xsl:value-of select="@loc"/>, <xsl:value-of select="@sal"/> <xsl:value-of select="@exp"/>, <xsl:value-of select="@sor"/> </li> </xsl:otherwise> </xsl:choose> </li> </xsl:for-each> </ol> </ol> </html> </body> </html> </xsl:template> </xsl:stylesheet> ------------------------------------------ </XSL code>----------------------------------- This seems to work OK, there is a bit of a hack as I end up doing a copy and paste of the output to convert it to a "html" webpage. Oh yes the other thing is that the secondary sort doesn't work too well (i.e. it does not work at all !) but then if life was perfect it would all be so boring....... At 14:10 07/06/87, you wrote: >I am trying to convert a web page that in essence is a directory >of members of a local association. A typical entry looks something >like this: > >ABC Company John Smith > 123 Main Street > john@xxxxxxxxx > >The last item, the email address, is presented as a link. In >other words, the actual html is > ><a href="mailto:john@xxxxxxxxx">john@xxxxxxxxx</a> > >I created an XML version of the directory along these lines > ><directory> ><member> ><company>ABC Company</company> ><contact>John Smith</contact> ><address>123 Main Street</address> ><email>john@xxxxxxxxx</email> ></member> >... ></directory> > >To display this as HTML, I created an XSL file with a ><xsl:for-each select="directory/member"> loop. The trouble >I'm having is with the email. I basically need to include >john@xxxxxxxxx both as a value for the href attribute and >as plain text. As far as I can tell, the commands cannot >be nested like this > > <a href="mailto:<xsl:value-of select="email"/>"><xsl:value-of >select="email"/></a> > >I tried escaping the angle brackets and quotes as follows: > > <a href="mailto:<xsl:value-of >select="email"/>"><xsl:value-of select="email"/></a><br /> > >but the resulting html displays the <a href= ...> instead of a >link. I'm using a Javascript under MSIE 6.0 to test the >transformation. > >It seems to me that this is not a unusual transformation but >I have looked in the XSL-List archives and XSL FAQ and couldn't >find anything on this topic. ==========-=.=........ -=-=-=== www.ContaminatedLand.co.uk======== \-=-/ Greetings contaminated earthling - you have accessed a worm-hole in the time-space continuum. In your world it is the second decade of the Great Helmsman "He-who-must-be-clicked" {William Three-bar Gates}. In our parallel universe he was burned at the stake in the Redmond Which Operating System Trials. Please be warned that Steve Balmer has acquired a Time-machine and is attempting to return to the 1980's to remake "Terminator 1" with Judge Thomas Penfield Jackson reprising Linda Hamilton's role If you should notice that the date header on this email says 1987 then you should either immediately destroy your Computer (whilst playing 'The Who' loudly) in order to prevent the universe being realigned, or else ask HAL nicely to open the pod door..... ==========-=.=........ -=-=-=== www.ContaminatedLand.co.uk======== XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Thread | [xsl] Transforming into embedded HT, jmabbate | |
Date | Re: [xsl] XSLT+XPATH as SVG scripti, Max Froumentin | |
Month |