Jump to content

Sudoku problem


lldonn
 Share

Recommended Posts

Hi I am trying to convert the following XML file into a 81 square Sudoku grid showing only selected numbers for selected cells, this is the problem that needs to be solved, my problem I am having is displying these selected numbers in the required cells in the 81 square grid. Can anyone please help me with my XSL file that i need to adjust to centre on the required cells and rows to pinpoint and select numebrs into their correct cells.XSL FILE:So far my results from using the gridy.xsl file are that I get 81 squares coming up, but each cell has three fullstops, which is wrong as there only needs to be one number in each celland I dont know how to do this part??!! I've tried a few ideas but there is no improvement.Below is the XML file that links the XSl file:<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="gridy.xsl"?><sml:grid xmlns:sml="http://www.w3.org/TR/WD-XS/sml"><sml:row id="1"> <sml:largesquare squareno="1"> <sml:smallrow rowid="1"> <sml:smallsquare cellid="1">3</sml:smallsquare> <sml:smallsquare cellid="2"></sml:smallsquare> <sml:smallsquare cellid="3"></sml:smallsquare> </sml:smallrow> <sml:smallrow rowid="2"> <sml:smallsquare cellid="4"></sml:smallsquare> <sml:smallsquare cellid="5">4</sml:smallsquare> <sml:smallsquare cellid="6"></sml:smallsquare> </sml:smallrow> <sml:smallrow rowid="3"> <sml:smallsquare cellid="7"></sml:smallsquare> <sml:smallsquare cellid="8"></sml:smallsquare> <sml:smallsquare cellid="9"></sml:smallsquare> </sml:smallrow> </sml:largesquare> <sml:largesquare squareno="2"> <sml:smallrow rowid="4"> <sml:smallsquare cellid="10"></sml:smallsquare> <sml:smallsquare cellid="11">6</sml:smallsquare> <sml:smallsquare cellid="12">5</sml:smallsquare> </sml:smallrow> <sml:smallrow rowid="5"> <sml:smallsquare cellid="13"></sml:smallsquare> <sml:smallsquare cellid="14"></sml:smallsquare> <sml:smallsquare cellid="15">9</sml:smallsquare> </sml:smallrow> <sml:smallrow rowid="6"> <sml:smallsquare cellid="16">3</sml:smallsquare> <sml:smallsquare cellid="17"></sml:smallsquare> <sml:smallsquare cellid="18"></sml:smallsquare> </sml:smallrow> </sml:largesquare> <sml:largesquare squareno="3"> <sml:smallrow rowid="7"> <sml:smallsquare cellid="19">7</sml:smallsquare> <sml:smallsquare cellid="20">4</sml:smallsquare> <sml:smallsquare cellid="21">2</sml:smallsquare> </sml:smallrow> <sml:smallrow rowid="8"> <sml:smallsquare cellid="22">3</sml:smallsquare> <sml:smallsquare cellid="23"></sml:smallsquare> <sml:smallsquare cellid="24">1</sml:smallsquare> </sml:smallrow> <sml:smallrow rowid="9"> <sml:smallsquare cellid="25">8</sml:smallsquare> <sml:smallsquare cellid="26"></sml:smallsquare> <sml:smallsquare cellid="27">5</sml:smallsquare> </sml:smallrow> </sml:largesquare></sml:row><sml:row id="2"> <sml:largesquare squareno="4"> <sml:smallrow rowid="10"> <sml:smallsquare cellid="28"></sml:smallsquare> <sml:smallsquare cellid="29">3</sml:smallsquare> <sml:smallsquare cellid="30"></sml:smallsquare> </sml:smallrow> <sml:smallrow rowid="11"> <sml:smallsquare cellid="31">5</sml:smallsquare> <sml:smallsquare cellid="32"></sml:smallsquare> <sml:smallsquare cellid="33">4</sml:smallsquare> </sml:smallrow> <sml:smallrow rowid="12"> <sml:smallsquare cellid="34">1</sml:smallsquare> <sml:smallsquare cellid="35"></sml:smallsquare> <sml:smallsquare cellid="36"></sml:smallsquare> </sml:smallrow> </sml:largesquare> <sml:largesquare squareno="5"> <sml:smallrow rowid="13"> <sml:smallsquare cellid="37"></sml:smallsquare> <sml:smallsquare cellid="38"></sml:smallsquare> <sml:smallsquare cellid="39"></sml:smallsquare> </sml:smallrow> <sml:smallrow rowid="14"> <sml:smallsquare cellid="40">6</sml:smallsquare> <sml:smallsquare cellid="41">7</sml:smallsquare> <sml:smallsquare cellid="42">2</sml:smallsquare> </sml:smallrow> <sml:smallrow rowid="15"> <sml:smallsquare cellid="43"></sml:smallsquare> <sml:smallsquare cellid="44"></sml:smallsquare> <sml:smallsquare cellid="45"></sml:smallsquare> </sml:smallrow></sml:largesquare><sml:largesquare squareno="6"> <sml:smallrow rowid="16"> <sml:smallsquare cellid="46"></sml:smallsquare> <sml:smallsquare cellid="47"></sml:smallsquare> <sml:smallsquare cellid="48">4</sml:smallsquare> </sml:smallrow> <sml:smallrow rowid="17"> <sml:smallsquare cellid="49">9</sml:smallsquare> <sml:smallsquare cellid="50"></sml:smallsquare> <sml:smallsquare cellid="51">3</sml:smallsquare> </sml:smallrow> <sml:smallrow rowid="18"> <sml:smallsquare cellid="52"></sml:smallsquare> <sml:smallsquare cellid="53">7</sml:smallsquare> <sml:smallsquare cellid="54"></sml:smallsquare> </sml:smallrow></sml:largesquare></sml:row><sml:row id="3"><sml:largesquare squareno="7"> <sml:smallrow rowid="19"> <sml:smallsquare cellid="55">8</sml:smallsquare> <sml:smallsquare cellid="56"></sml:smallsquare> <sml:smallsquare cellid="57">1</sml:smallsquare> </sml:smallrow> <sml:smallrow rowid="20"> <sml:smallsquare cellid="58">4</sml:smallsquare> <sml:smallsquare cellid="59"></sml:smallsquare> <sml:smallsquare cellid="60">6</sml:smallsquare> </sml:smallrow> <sml:smallrow rowid="21"> <sml:smallsquare cellid="61">9</sml:smallsquare> <sml:smallsquare cellid="62">2</sml:smallsquare> <sml:smallsquare cellid="63">3</sml:smallsquare> </sml:smallrow></sml:largesquare><sml:largesquare squareno="8"> <sml:smallrow rowid="22"> <sml:smallsquare cellid="64"></sml:smallsquare> <sml:smallsquare cellid="65"></sml:smallsquare> <sml:smallsquare cellid="66">6</sml:smallsquare> </sml:smallrow> <sml:smallrow rowid="23"> <sml:smallsquare cellid="67">2</sml:smallsquare> <sml:smallsquare cellid="68"></sml:smallsquare> <sml:smallsquare cellid="69"></sml:smallsquare> </sml:smallrow> <sml:smallrow rowid="24"> <sml:smallsquare cellid="70">5</sml:smallsquare> <sml:smallsquare cellid="71">1</sml:smallsquare> <sml:smallsquare cellid="72"></sml:smallsquare> </sml:smallrow></sml:largesquare><sml:largesquare squareno="9"> <sml:smallrow rowid="25"> <sml:smallsquare cellid="73"></sml:smallsquare> <sml:smallsquare cellid="74"></sml:smallsquare> <sml:smallsquare cellid="75"></sml:smallsquare> </sml:smallrow> <sml:smallrow rowid="26"> <sml:smallsquare cellid="76"></sml:smallsquare> <sml:smallsquare cellid="77">3</sml:smallsquare> <sml:smallsquare cellid="78"></sml:smallsquare> </sml:smallrow> <sml:smallrow rowid="27"> <sml:smallsquare cellid="79"></sml:smallsquare> <sml:smallsquare cellid="80"></sml:smallsquare> <sml:smallsquare cellid="81">6</sml:smallsquare> </sml:smallrow></sml:largesquare></sml:row></sml:grid>BElow is the XSL file that converts the XML above to the 81 square grid<?xml version="1.0"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl"><xsl:template match="/"><html><head></head><body> <xsl:apply-templates select="sml:grid"/></body></html></xsl:template><xsl:template match="sml:grid"><table border="2"><tr><xsl:for-each select="sml:row"> <tr> <xsl:for-each select="sml:largesquare"> <td> <table border="3"> <tr> <xsl:for-each select="sml:smallrow"> <tr> <xsl:for-each select="sml:smallsquare"> <td> <table> <td class="sml:smallsquare1"> .<xsl:value-of select="sml:smallsquare1"/> </td> <td class="sml:smallsquare2"> .<xsl:value-of select="sml:smallsquare2"/> </td> <td class="sml:smallsquare3"> .<xsl:value-of select="sml:smallsquare3"/> </td> </table> </td> </xsl:for-each> </tr> </xsl:for-each> </tr> </table> </td> </xsl:for-each> </tr> </xsl:for-each></tr> </table><!--End of large 2 coloumn--></xsl:template></xsl:stylesheet>These three lines below taken from the code above show where the three fullstops come from, they represent three rows in each 9 large squares of the 81 square grid, what i want to find out is how to change these full stops to numbers now????ANY IDEAS Out there ANY HELP WOULD be greatly appreciated!!!!<td class="sml:smallsquare1"> .<xsl:value-of select="sml:smallsquare1"/> </td> <td class="sml:smallsquare2"> .<xsl:value-of select="sml:smallsquare2"/> </td> <td class="sml:smallsquare3"> .<xsl:value-of select="sml:smallsquare3"/> </td>

Link to comment
Share on other sites

<?xml version="1.0"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl"><xsl:template match="/"><html><head></head><body>	<xsl:apply-templates select="sml:grid"/></body></html></xsl:template><xsl:template match="sml:grid"><table border="2"><xsl:for-each select="sml:row">	<tr> 	<xsl:for-each select="sml:largesquare">		<td>  <table border="3">  <xsl:for-each select="sml:smallrow">    <tr>   <xsl:for-each select="sml:smallsquare">         	 <td class="sml:smallsquare1"> .<xsl:value-of select="sml:smallsquare"/> </td>       	 </xsl:for-each>    </tr>     	      </xsl:for-each>    </table>	</td>	</xsl:for-each>	</tr>	</xsl:for-each></tr>	</table><!--End of large 2 coloumn--></xsl:template></xsl:stylesheet>

that should fix it, sorry about the indentation, that kinda got messed up :) LG

Link to comment
Share on other sites

Just curious... isn't XSLT's namespace actually:

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...