Wrox Programmer Forums
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 8th, 2006, 05:12 PM
Registered User
 
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sudoku

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>



</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>

 
Old October 12th, 2007, 09:53 AM
Authorized User
 
Join Date: Mar 2005
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to aehb
Default

Check my VC++ sudoku solver
http://rapidshare.com/files/62022489/Sudoku_Solver.rar






Similar Threads
Thread Thread Starter Forum Replies Last Post
Sudoku solver aehb Visual C++ 3 November 12th, 2011 07:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.