|
||
| Inside Technique : XML-Based Survey Server : Core ASP Functions The The survey.inc file contains three functions for retrieving surveys, saving votes, and listing
all surveys on the system. When you want to insert a survey into your page, you call the The getSurvey() function extracts both the survey and the XSL block based on the
passed in identifiers. The returned XSL block is then applied to the survey and
returned from the function:
The function extracts the survey and applies it to the appropriate XSL block by executing queries against the XML.
When examining the above function, notice the two calls to selectSingleNode.
This method is used to locate the specific survey and rendering scheme.
For example, the query that retrieves the survey with ID of "1"
searches for the single survey node that contains the ID node with the value of "1":
Examining this query, the "/" is used to define the context we are searching in.
The square brackets "[" are
used to do deeper searches without switching the context. This query is looking
for the survey node within the surveylist node that contains an id node of the value 1.
By using the square brackets, we are specifying that we want the survey node returned
even though we are searching the survey's contents. When the above query is run against
our sample surveys, the following sub-tree is returned:
The rendering query works essentially the same way. The primary difference is we
are matching the render node's ID attribute instead of an ID element. This
is done using the "@" operator:
This returns the render element for the vBanner and provides access to the complete
render sub-tree:
Finally we execute the transformNode function with the returned XSL node against the survey. Since the survey's output is always the same there is no need to regenerate the output on every request. Therefore, to improve performance we cache the generated output in the application object. If you modify the XSL sheets to include dynamic information (eg., total votes, etc), you may need to modify our caching scheme. In our next section, we show you how a user's vote is processed and how the results are rendered. Page 1:XML-Based Survey Server © 1997-2000 InsideDHTML.com, LLC. All rights reserved. |