I am building a website using ASP, XML, and XSL to learn more about these technologies. I have come up with a way of accessing ASP variables within my XSL templates and this allows me to call different templates based on different conditions. This allows me to greatly simplify my ASP code in that all it really has to do is transform one XML file into XHTML, but it can produce many different results based on values passed in the querystring. Everything seems to work fine, I am just wondering about performance down the road as the application grows as well as future projects.
Does an xsl file that has multiple xsl include files have to "process" all of these templates even if they are not being used at that particular time. In other words, if I have something like what is shown below, will I end up with poor performance?
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="
http://www.w3.org/1999/XSL/Transform">
<xsl:import href="one.xsl"/>
<xsl:import href="two.xsl"/>
<xsl:import href="three.xsl"/>
<xsl:import href="four.xsl"/>
<xsl:import href="five.xsl"/>
<xsl:template match="/foo">
<xsl:choose>
<xsl:when test="$strOperation = 'this'">
<xsl:call-template name="one" />
</xsl:when>
<xsl:when test="$strOperation = 'that'">
<xsl:call-template name="two" />
</xsl:when>
<xsl:when test="$strOperation = 'something'">
<xsl:call-template name="three" />
</xsl:when>
<xsl:when test="$strOperation = 'somevalue'">
<xsl:call-template name="four" />
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="five"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
The second part of my question involves the use of the "msxsl:node-set" function. My site has an administration piece that allows me to edit the content of various entries. Some of the content on the site needs to only be visible to the administrator (which I can detect in a variable in my XSL). So my xml data would look something like this:
<post>
<approved>True</approved>
<entry>this is sample data</entry>
</post>
<post>
<approved>False</approved>
<entry>this is sample data also</entry>
</post>
When I display this data on a page, I would want it to be visible to the admin (as well as display additional buttons, etc). This occurs in different sections all over the site. My thought was to create a variable containing the XML to be used which is different based on whether the user is logged in as the admin or not. So it would look something like this:
<xsl:variable name="SiteXML">
<xsl:choose>
<xsl:when test="$blnLoggedIn = 'True'">
<!--everything is included-->
<post>
<approved>True</approved>
<entry>this is sample data</entry>
</post>
<post>
<approved>False</approved>
<entry>this is sample data also</entry>
</post>
</xsl:when>
<xsl:otherwise>
<!--only approved items are included-->
<post>
<approved>True</approved>
<entry>this is sample data</entry>
</post>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
Then I only have to maintain one XSL stylesheet for this portion, by using this variable as my source data, by doing this:
<xsl:for-each select="msxsl:node-set($Si
teXML)">
display stuff here
</xsl:for-each>
This whole thing was done simply for me to learn more about XML and XSL, so I just want to make sure I am not totally off track by going about things this way, and I figured I could get some constructive criticism here.