title: How to check radio buttons based upon returned XML data using an XSLT
body: <p>Hey I'm pretty new to XSLT's and trying to get my head around using them to produce and populate a form. I have made the XSLT and can get the XML data from the server and I think I have correctly matched up all the fields etc with their respective XML data. However I can't work out how to make radio buttons and checkboxes checked depending on the stored XML data. I have found a couple of similar posts on the net but I cannot make them function correctly and was hoping someone on here might be able to give me a hand.</p>
  
  <p>I have made some small test code with which to try and get this working as I didn't want to risk messing up the full form. The test XML and XSL are shown below.</p>
  
  <p>XML</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="test2.xsl"?&gt;
  &lt;root&gt;
  &lt;radiobuttons&gt;
      &lt;radio1&gt;Y&lt;/radio1&gt;
      &lt;blurb&gt;blahblahblah&lt;/blurb&gt;
  &lt;/radiobuttons&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>XSL</p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
      &lt;xsl:output method="html" indent="yes" omit-xml-declaration="no"
              encoding="UTF-8"/&gt;
  &lt;xsl:template match="/"&gt;
  &lt;HTML&gt;
  &lt;BODY&gt;
  &lt;form&gt;
  &lt;xsl:apply-templates select="root"/&gt;
  &lt;/form&gt;
  &lt;/BODY&gt;
  &lt;/HTML&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="root"&gt;
  
  &lt;input type="radio" name="radio1" value="Y" &gt;
  &lt;xsl:if test="root/radiobuttons/radio1='Y'"&gt;
  &lt;xsl:attribute name="checked"&gt;checked&lt;/xsl:attribute&gt;&lt;/xsl:if&gt;
  &lt;/input&gt;Radio Button 1
  
  &lt;input type="radio" name="radio1" value="N" &gt;
  &lt;xsl:if test="root/radiobuttons/radio1='N'"&gt;
  &lt;xsl:attribute name="checked"&gt;checked&lt;/xsl:attribute&gt;&lt;/xsl:if&gt;
  &lt;/input&gt;Radio Button 2
  
  &lt;br/&gt;
  &lt;input name="blurb" type="text" id="blurb" value="{./radiotbuttons/blurb}"&gt;&lt;/input&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>I'd like the first radio button to be checked in the resulting HTML if the XML has a value of Y stored and the 2nd buton if it has a value of N. If anyone can shed some light on why this isn't working or if it is completely the wrong approach then give me a correct example I'd be really grateful.</p>