Create Your Own STOR
ASPAlliance.com: The #1 ASP.NET Community
The ASPSmith
Search
D: | Domains | Authors.aspalliance.com | Stevesmith | Articles | Create Your Own STOR
Create Your Own STOR

By Steven Smith

[Example]
NOTE: As of June 2001, STORS.org is defunct and has been replaced with ASPRSS.com. Please refer to that website for more information, including ASPAlliance's RSS document. Thanks!

STOR, or Shared Table Of Resources, is a new standard for sharing information about online resources. ASPAlliance.com is one of the founding members of the STOR standard, and is actively supporting and promoting its use. You can read more about the STOR standard at its website, STORS.org.

This article provides a working example of how to create a STOR programmatically from a database of links. The ASPAlliance site has a backend database with a links table already, as well as a COM object for retrieving links for a particular columnist. In this example, we will look at how the STOR file located at http://aspalliance.com/stevesmith/stor.xml was created.

   <%Option Explicit%>
   <object progid="Scripting.FileSystemObject" id="objFSO" runat="server"></object>
   <object progid="SSLibrary.Library" id="objLib" runat="server"></object>
   <object progid="ASPAlliance.Read" id="objAspRead" runat="server"></object>
   <%
   Dim strFileName
   Dim objFile
   Dim strVFileName
   Dim objRs
10   Dim arrArticles
11   Dim I
12   
13   'directory where the textfile lives. Ex d:/inetpub/wwwroot/people/
14   strVFileName = "/stevesmith/stor.xml"
15   strFileName = server.mappath(strVFileName)
16   
17   set objFile=objFSO.OpenTextFile(strFileName, ForWriting)
18   
19   'Create the standard header for the STOR
20   objFile.WriteLine "<?xml version=""1.0"" encoding=""UTF-8""?>"
21   objFile.WriteLine "<resources xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:noNamespaceSchemaLocation=""http://stors.org/stor.xsd"">"
22   objFile.WriteLine "<!-- Validate this STOR here: http://stors.org/STORform.asp -->"
23   
24   'Reference any related STORs -- in this case the ASPAlliance.com root STOR
25   objFile.WriteLine "<other_stor_url>http://aspalliance.com/stor.xml</other_stor_url>"
26   
27   'Add Publisher Node (don't close the node)
28   objFile.WriteLine "<publisher>"
29   objFile.WriteLine "<name>ASPAlliance.com: StevenatorASP</name>"
30   objFile.WriteLine "<url>http://ASPAlliance.com/stevesmith/</url>"
31   objFile.WriteLine "<logo_url>http://ASPAlliance.com/images/aspalliance_100x30.gif</logo_url>"
32   objFile.WriteLine "<address>ASPAlliance.com, P.O. Box 1856, Kent, OH, 44240, USA</address>"
33   objFile.WriteLine "<description>Steve Smith's ASP/ASP.NET Resource Site.</description>"
34   objFile.WriteLine "<author>"
35   objFile.WriteLine "<email>ssmith@aspalliance.com</email>"
36   objFile.WriteLine "<full_name>Steven Smith</full_name>"
37   objFile.WriteLine "</author>"
38   
39   'Add Resources
40   'ListArticlesForColumnist returns a recordset with all the links to a particular columnist's articles.
41   'ID 1 is Steve Smith
42   Set objRs = objAspRead.ListArticlesForColumnist(1)
43   If Not objRs.EOF Then
44    'Use GetRows because it's much faster than iterating through the recordset.
45    'Transpose just flips the axes of the array.
46    arrArticles = objLib.Transpose(objRs.GetRows)
47   End if
48   objRs.Close
49   
50   'Output Array to Screen For Debugging
51   'DisplayArray is a utility function that dumps out an array's contents as table cells.
52   If Request("debug") <> "" Then
53    Response.Write "<table>" & objLib.DisplayArray(arrArticles) & "</table>"
54    Response.Write "Height: " & UBound(arrArticles,1) & "; Width: " & UBound(arrArticles,2) & "<br>"
55   End If
56   
57   'Add Resources
58   For I = 0 To UBound(arrArticles,1)
59    'Add a Resource
60    objFile.WriteLine "<resource>"
61    objFile.WriteLine "<url>" & arrArticles(I,1) & "</url>"
62    objFile.WriteLine "<title>" & arrArticles(I,2) & "</title>"
63    objFile.WriteLine "<description>" & arrArticles(I,5) & "</description>"
64   
65    'Determine an appropriate topic. If the topics stored in your database do not
66    'match the STORS topics (http://stors.org/topics.asp), then we need to somehow
67    'map between them. When in doubt, I use "ASP - Active Server Pages".
68    If Instr(1, LCase(arrArticles(I,5) & " " & arrArticles(I,2)), "asp.net") > 0 Then
69    objFile.WriteLine "<topic>ASP.NET - Active Server Pages.NET</topic>"
70    ElseIf Instr(1, LCase(arrArticles(I,5) & " " & arrArticles(I,2)), "sql") > 0 Then
71    objFile.WriteLine "<topic>SQL Server</topic>"
72    Else
73    objFile.WriteLine "<topic>ASP - Active Server Pages</topic>"
74    End If
75    'I don't need any comments, but they're supported if I did.
76    'objFile.WriteLine "<comment>Anything can go here...</comment>"
77    objFile.WriteLine "<keywords>ASPAlliance, Article, Steven Smith</keywords>"
78    objFile.WriteLine "<publish_date>" & Year(arrArticles(I,3)) & "-" & Right(0 & Month(arrArticles(I,3)),2) & "-" & Right(0 & Day(arrArticles(I,3)),2) & "</publish_date>"
79    objFile.WriteLine "<update_date>" & Year(arrArticles(I,4)) & "-" & Right(0 & Month(arrArticles(I,4)),2) & "-" & Right(0 & Day(arrArticles(I,4)),2) & "</update_date>"
80    objFile.WriteLine "</resource>"
81   Next
82   'Close all nodes
83   objFile.WriteLine "</publisher>"
84   objFile.WriteLine "</resources>"
85   objFile.close
86   set objFile=nothing
87   %>

88   <a href="<%=strVFileName%>">STOR.xml</a><br/>

I documented the code in-line. Unfortunately, since the code modifies a file on the web server, it requires write permissions and so is not accessible to anonymous users. This example is pretty much just a single, linear piece of code. STORS.org has more generic, modular examples for how to implement a STOR on your site, as well as sample code for directory sites to use to accept STORS on their sites.


Reference Links:





ASP.NET Developer's Cookbook, By Steven Smith, Rob Howard, ASPAlliance.com 

ASP.NET By Example, By Steven Smith 




Steven Smith, MCSE + Internet (4.0)
Last Modified: 6/12/2009 10:58:24 AM
History: 6/12/2009 10:58:24 AM