Click here to Skip to main content
15,881,852 members
Articles / Programming Languages / XSLT

Custom Configuration SQL Connection String Section

Rate me:
Please Sign up or sign in to vote.
3.42/5 (7 votes)
23 Jan 2006CPOL5 min read 90.2K   1K   24  
This solution demonstrates enforcing valid SQL connection strings in the App.Config file.
<?xml version="1.0" encoding="UTF-8"?>
<!--
Fair License

Copyright (c) 2005 Theodore William Bouskill

Usage of the works is permitted provided that this
instrument is retained with the works, so that any entity
that uses the works is notified of this instrument.

DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:import href="SqlConnectionStringCollection2.xslt"/>
	<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:template match="/">
		<html>
		<head>
			<title>SqlConnection Strings</title>
			<style type="text/css">
			TABLE {
				BORDER-COLLAPSE: collapse;
				TABLE-LAYOUT: fixed;
			}
			TH {
				FONT-WEIGHT: bold; FONT-SIZE: larger; FONT-FAMILY: Verdana, Arial, Helvetica, Sans-Serif;
				BORDER-BOTTOM: black 1px solid;
			}
			TD {
				BORDER-BOTTOM: 0x111111 1px solid;
				FONT-FAMILY: Verdana, Arial, Helvetica, Sans-Serif;
			}
			TD.Required {
				BORDER-LEFT: 0x222222 2px solid;
				TEXT-TRANSFORM: uppercase;
			}
			TD.SqlConnectionString {
				BORDER-LEFT: 0x222222 2px solid;
				FONT-WEIGHT: bold; FONT-FAMILY: "Courier New", Courier, Mono;
			}
			</style>
		</head>
		<body>
		<table border="0" cellpadding="2" cellspacing="0">
		<tr>
			<th align="left" width="150">Key</th>
			<th style="BORDER-LEFT: 0x222222 2px solid;" align="center" width="100">Required</th>
			<th style="BORDER-LEFT: 0x222222 2px solid;" align="left">SqlConnection String</th>
		</tr>
		<xsl:apply-templates/>
		</table>
		</body>
		</html>
	</xsl:template>
	<xsl:template match="SqlConnectionString">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="SqlConnectionString">
		<tr>
			<td align="left"><xsl:value-of select="@ID"/></td>
			<td class="Required" align="center">
				<xsl:choose>
					<xsl:when test="@Required"><xsl:value-of select="@Required"/></xsl:when>
					<xsl:otherwise>False</xsl:otherwise>
				</xsl:choose> 
			</td>
			<td class="SqlConnectionString" align="left">
				<xsl:apply-templates select="Authentication"/>
				<xsl:apply-templates select="ConnectionPooling"/>
				<xsl:apply-templates select="Connectivity"/>
				<xsl:if test="CurrentLanguage">Current Language=<xsl:value-of select="CurrentLanguage"/>; </xsl:if>
				<xsl:apply-templates select="Database"/>
				<xsl:apply-templates select="Identification"/>
				<xsl:choose>
					<xsl:when test="Server"><xsl:apply-templates select="Server"/></xsl:when>
					<xsl:otherwise>Server=(local);</xsl:otherwise>
				</xsl:choose>				
			</td>
		</tr>
	</xsl:template>
</xsl:stylesheet>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Canada Canada
Very experienced Senior Software Developer/Manager with natural leadership and proven project management skills.

Started in Civil Engineering leading the integration of PC's into the Engineering process as a Design/Drafting Technician as well as an in-house Software Developer then transitioned into a full time Software Development career in the early 90's.

Ability to change and adapt has led to diverse experience with a wide array of technology and roles from graphics or web development to designing line of business enterprise applications.

Knowledge Base: Sharepoint, C#, SQL, ASP.NET, C++, CSS, HTML, JavaScript, XML, XSLT

Comments and Discussions