XSLT - Input and Output of text

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello I need some help with the input of my xslt program (possible using Link and parse) and also with the output of the text. Any help or refrence tools would be very helpful.... I have been trying for a while and cant see to get it right. Thank
you.

<pre class="prettyprint <?xml version="1.0"?>


<grid>
<row id = "1

<column id="1" > 0 </column>

<column id="2" > 1 </column>

<column id="3" > 0 </column>

<column id="4" > 1 </column>

</row>
<row id = "2

<column id="1" > 0 </column>

<column id="2" > 1 </column>

<column id="3" > 0 </column>

<column id="4" > 1 </column>

</row>
<row id = "3

<column id="1" > 0 </column>

<column id="2" > 1 </column>

<column id="3" > 0 </column>

<column id="4" > 1 </column>

</row>
<row id = "4

<column id="1" > 0 </column>

<column id="2" > 1 </column>

<column id="3" > 0 </column>

<column id="4" > 1 </column>

</row>
</grid>[/code]
<br/>
<pre class="prettyprint <?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform
<xsl:template match="/
<HTML>
MINESWEEPER
<table border="4
<tr bgcolor="#9acd32

<th>COLUMN 1</th>
<th>COLUMN 2</th>
<th>COLUMN 3</th>
<th>COLUMN 4</th>
</tr>

<xsl:for-each select="grid/row
<tr>
<xsl:variable name="currRow" select="@id"/>
<xsl:for-each select="column
<xsl:variable name="currColumn" select="@id"/>
<xsl:choose>
<xsl:when test=".= 0 <!--bomb-->
<td>*</td>
</xsl:when>
<xsl:otherwise>
<td><xsl:value-of select="count(../../row[(@id = $currRow - 1) or (@id = $currRow) or (@id = $currRow + 1)]/column[((@id = $currColumn - 1) or @id =$currColumn or (@id =$currColumn +1)) and .= 0 ])
" />
</td>
</xsl:otherwise>
</xsl:choose>



</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</HTML>
</xsl:template>
</xsl:stylesheet>[/code]
<br/>

View the full article
 
Back
Top