title: XSL namespaces and xsl:for-each
body: <p>I'm currently stuck trying to use XSL to transform a XML document into HTML. The XML document uses namespaces and I don't really have too much experience with XSL let alone namespaces. Basically all I want to do is grab every instance of s:treatment and output this as a list. I've changed data so not to expose the website I'm doing this for. I'm using Classic ASP (can't update to ASP.NET) to transform the XML on the server, so the XSL has to be version 1 :(</p>
  
  <p>Any help would be really appreciated here as I just can't figure out what's going wrong. </p>
  
  <p>Here's the XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;feed xmlns="http://www.w3.org/2005/Atom"&gt;
  &lt;title type="text"&gt;a&lt;/title&gt;
  &lt;id&gt;a&lt;/id&gt;
  &lt;rights type="text"&gt;© Crown Copyright 2009&lt;/rights&gt;
  &lt;updated&gt;2011-01-19T11:23:25Z&lt;/updated&gt;
  &lt;category term="Service"/&gt;
  &lt;author&gt;
   &lt;name&gt;c&lt;/name&gt;
  &lt;uri&gt;http://www.meh.com&lt;/uri&gt;
   &lt;email&gt;erwt&lt;/email&gt;
   &lt;/author&gt;
  &lt;complete xmlns="http://purl.org/syndication/history/1.0"/&gt;
  &lt;entry&gt;
   &lt;id&gt;http://meh.com/services&lt;/id&gt;
   &lt;title type="text"&gt;title&lt;/title&gt;
   &lt;updated&gt;2010-06-18T19:52:12+01:00&lt;/updated&gt;
   &lt;link rel="self" title="title" href="meh"/&gt;
   &lt;link rel="alternate" title="title" href="id"/&gt;
   &lt;content type="application/xml"&gt;
   &lt;s:service xmlns:s="http://syndication.nhschoices.nhs.uk/services"&gt;
    &lt;s:type code="S"&gt;h&lt;/s:type&gt;
    &lt;s:deliverer&gt;j&lt;/s:deliverer&gt;
    &lt;s:parent&gt;k&lt;/s:parent&gt;
    &lt;s:treatments&gt;
     &lt;s:treatment&gt;fissure&lt;/s:treatment&gt;
     &lt;s:treatment&gt;fistula&lt;/s:treatment&gt;
     &lt;s:treatment&gt;liver&lt;/s:treatment&gt;
     &lt;s:treatment&gt;pancreas&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Cirrhosis&lt;/s:treatment&gt;
       &lt;s:treatment&gt;Coeliac disease&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Crohn's disease&lt;/s:treatment&gt;
      &lt;s:treatment&gt;Diagnostic endoscopy of the stomach&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Diverticular problems&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Gastrectomy&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Gastroenteritis&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Gastroenterology&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Gastroesophageal reflux disease(GORD)&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Hepatitis&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Hepatitis A&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Hepatitis B&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Hepatitis C&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Hernia hiatus&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Ileostomy&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Irritable bowel syndrome&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Liver disease (alcoholic)&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Obesity&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Pancreatitis&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Peptic ulcer&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Peritonitis&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Primary biliary cirrhosis&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Surgery for haemorrhoids&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Therapeutic endoscopy on the stomach&lt;/s:treatment&gt;
     &lt;s:treatment&gt;Ulcerative colitis&lt;/s:treatment&gt;
    &lt;/s:treatments&gt;
    &lt;s:phone&gt;020 8&lt;/s:phone&gt;
    &lt;s:fax&gt;020 8&lt;/s:fax&gt;
    &lt;s:email&gt;jj&lt;/s:email&gt;
    &lt;s:website&gt;oiyi&lt;/s:website&gt;
   &lt;/s:service&gt;
  &lt;/content&gt;
   &lt;/entry&gt;
   &lt;/feed&gt;
  </code></pre>
  
  <p>As you can see it uses the Atom namespace, Purl syndication namespace and NHS Choices namespace only the NHS Choices namespace actually uses the prefix though, this is what is confusing me really. How would I declare the other namespaces and do I even need to?</p>
  
  <p>Here's my XSL:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:s="http://syndication.nhschoices.nhs.uk/services"&gt;
  &lt;ul&gt;
  &lt;xsl:template match="/"&gt;
  
  &lt;xsl:for-each select="feed/entry/content/s:service/s:treatments/s:treatment"&gt;
  &lt;li&gt;&lt;xsl:text&gt;&lt;/xsl:text&gt;&lt;/li&gt;
  &lt;/xsl:for-each&gt;
  
  &lt;/xsl:template&gt;
   &lt;/ul&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>This XSL was taken from the w3schools example so apologies if it's bare.</p>
  
  <p>Any ideas what I need to do to make this work?</p>
  
  <p>Thanks,
  Colin</p>