They call this an XML feed?
I struggled with this at first, until I realized that they have not only
committed the crime of escaping the nested markup so that < is written as
<, they have actually double-escaped it so that it is written as &lt;
This must be the most perverse XML document I have seen for a long time.
Using disable-output-escaping will compensate for a single level of
unnecessary escaping in the input, but it won't compensate for two levels.
If your project allows you to use Saxon, I would suggest
<p>1) <xsl:value-of select="saxon:parse(concat('<d>',
@description, '</d>'))"
disable-output-escaping="yes"
xmlns:saxon="http://saxon.sf.net/"/></p>
which does the trick. Horrible input sometimes demands a horrible
stylesheet.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: G(_dot_)Wenden(_at_)liverpool(_dot_)ac(_dot_)uk
[mailto:G(_dot_)Wenden(_at_)liverpool(_dot_)ac(_dot_)uk]
Sent: 27 April 2005 10:15
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Getting useful data from this XML
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=59d620a61d0ba0dd29dc0c4cebefce81&id=1647&lt;/a&
amp;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[(_at_)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>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--