*
*
*
*
Register | Login 
Articles

Current Articles | Categories | Search | Syndication

Tuesday, October 23, 2007
How To Use an XSL file with SQLView
By dnnstuffadmin @ 8:52 AM :: 768 Views :: 2 Comments :: :: SQLView, How-To
 

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
 
Rating
Comments
By Paul Hebhardt @ Tuesday, August 26, 2008 11:43 PM
The xsl that you supplied didn't work when I used it in my version of DNN 4.8.4. I had to use the following xslt:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="SQLData">
<B>Report</B>
<BR/>
<TABLE CELLPADDING="1" CELLSPACING="1" Border="1">
<TR>
<TH>Tab Number</TH>
<TH>Tab Name</TH>
</TR>
<xsl:for-each select="Rows">
<TR>
<TD>
<xsl:value-of select="TabID"/>
</TD>
<TD>
<xsl:value-of select="TabName"/>
</TD>
</TR>
</xsl:for-each>
</TABLE>
</xsl:template>
</xsl:stylesheet>

ByRichard @ Wednesday, August 27, 2008 7:13 AM
Thanks Paul,

I made a minor change to the SQLView code to use SQLData as the top level entity instead of NewDataSet and forget to make the change here.

Click here to post a comment

By Category

By Date

DotNetNuke Powered!

Copyright (c) 2005-2008 DNNStuff
*
Terms Of Use   Privacy Statement