dnnstuffadmin posted on October 23, 2007 08:52

ED Note: Please make sure you have the latest release of SQLView (at time of this edit it's at 04.00.04) so that the xml generated is consistent with this article. A debug option has also been added in 04.00.04 which shows you the xml generated to make it easier to write your xsl.
Back to the task at hand:
There has been a little confusion lately about how to use the xsl feature of SQLView to present data so I've put together the following simple example.
In this example, I'm going to show the Tabs table in a table but this table is generated through xsl and not through the standard grid.
Step 1: Create the following xsl file and name is TabsAsTable.xsl and put it into the root of your portal, ie. portals/0 folder etc.
1:<xsl:stylesheet version="1.0"
2:xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3:<xsl:template match="SQLData">
4:<B>Report</B><BR/>
5:<TABLE CELLPADDING="1" CELLSPACING="1" Border="1">
6:<TR><TH>Tab Number</TH>
7:<TH>Tab Name</TH>
8:</TR>
9:<xsl:for-each select="Table">
10:<TR>
11:<TD><xsl:value-of select="TabID"/></TD>
12:<TD><xsl:value-of select="TabName"/></TD>
13:</TR>
14:</xsl:for-each>
15:</TABLE>
16:</xsl:template>
17:</xsl:stylesheet>
Step 2: Setup your SQLView module
Add a SQLView module to your page and for the query text enter, SELECT * FROM Tabs. (you may have to append your objectQualifier onto Tabs, such as DNN_Tabs if you use an objectQualifier)
If you save this and go back to the page you should see all of your tabs in a simple grid. Now, go back into the sqlview module and in the xsl section choose the file that you saved previously, TabsAsTable.xsl. Save the settings a second time and you will see another table of the tabs but this time it is presented using the xsl. Go ahead and change the table headings in the xsl and then refresh the page and you'll see that they change.
The intricasies of xsl are well beyond this article but a simple search will show you many resources which deal with this powerful technology.
For reference purposes, the xml produced before being sent to the xsl will look like the following:
1:<SQLData>
2:<Table>
3:<TabID>7</TabID>
4:<TabOrder>1</TabOrder>
5:<TabName>Host</TabName>
6:<IsVisible>true</IsVisible>
7:<Level>0</Level>
8:<IconFile />
9:<DisableLink>true</DisableLink>
10:<Title />
11:<Description />
12:<KeyWords />
13:<IsDeleted>false</IsDeleted>
14:<Url />
15:<TabPath>//Host</TabPath>
16:</Table>
17:<Table>
18:<TabID>65</TabID>
19:<TabOrder>13</TabOrder>
20:<PortalID>0</PortalID>
21:<TabName>SQLView Pro</TabName>
22:<IsVisible>true</IsVisible>
23:<Level>0</Level>
24:<IconFile />
25:<DisableLink>false</DisableLink>
26:<Title />
27:<Description />
28:<KeyWords />
29:<IsDeleted>false</IsDeleted>
30:<Url />
31:<TabPath>//SQLViewPro</TabPath>
32:</Table>
33:</SQLData>
ED: Changed to reflect change to SQLView, namely renaming of NewDataSet element to SQLData