Subject: [xsl] Getting useful data from this XML From: "G.Wenden@xxxxxxxxxxxxxxx" <G.Wenden@xxxxxxxxxxxxxxx> Date: Wed, 27 Apr 2005 10:15:07 +0100 |
I'm trying to write an xsl that will allow me to show whether there are any problems on our local rail lines. The train company provide an XML feed but I'm having trouble getting any useful data out of it. I've tried a couple of different approaches but the data that comes out has HTML tags that are displayed rather than used. Thanks, Greg Here is an example XML file <?xml version="1.0" encoding="iso-8859-1" ?> <?xml-stylesheet type="text/xsl" href="new.xsl"?> <!-- Number of disruption/incidents : 'num_incidents' attrbute. Where there are no disruptions, we recommend that you simply state: 'Services running normally.' --> <!DOCTYPE merseyrail [ <!ELEMENT merseyrail (incident?)> <!ATTLIST merseyrail num_incidents CDATA "0"> <!ELEMENT incident (EMPTY)> <!ATTLIST incident description CDATA #IMPLIED> <!ATTLIST incident details_url CDATA #IMPLIED> ]> <merseyrail num_incidents='1'> <incident description="09.15 &lt;B&gt;Chester&lt;/B&gt; to &lt;B&gt;Liverpool&lt;/B&gt; will start at &lt;B&gt;Hooton&lt;/B&gt;." details_url="&lt;a href=&quot;http://www.merseyrail.org/travelling/?sSrc=&sGUID=59d620a6 1d0ba0dd29dc0c4cebefce81&id=1647&lt;/a&gt;" /> </merseyrail> And here is the xsl that I have written. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:output method="html"/> <xsl:template match="/"> <html> <head> <title>Merseyrail Service Announcement</title> </head> <body> <xsl:for-each select="merseyrail/incident"> <xsl:if test="position()=1"> <h1>Merseyrail services are NOT running normally.</h1> </xsl:if> <p>1) <xsl:value-of select="@description" disable-output-escaping="yes"/></p> <p>2) <xsl:value-of select="@description" /></p> <p>3) <xsl:value-of select="@details_url" disable-output-escaping="yes"/></p> </xsl:for-each> <xsl:for-each select="merseyrail[@num_incidents='0']"> <h1>Merseyrail services are running normally.</h1> </xsl:for-each> <p> This information is taken from <a href="http://www.merseyrail.org">www.merseyrail.org</a></p> </body> </html> </xsl:template> </xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] logic for writing two nes, Jon Gorman | Thread | RE: [xsl] Getting useful data from , Michael Kay |
RE: [xsl] xsl apply template is not, Michael Kay | Date | Re: [xsl] Should XSLT be used to ge, Jirka Kosek |
Month |