Index: /greenstone3/trunk/web/ui/xslt/preProcess.xsl
===================================================================
--- /greenstone3/trunk/web/ui/xslt/preProcess.xsl	(revision 20149)
+++ /greenstone3/trunk/web/ui/xslt/preProcess.xsl	(revision 20150)
@@ -2,150 +2,144 @@
 
 <xsl:stylesheet version="1.0" 
-xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
-xmlns:gslib="http://www.greenstone.org/skinning"
-xmlns:java="http://xml.apache.org/xslt/java"
-xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
-xmlns:xalan="http://xml.apache.org/xalan"
-xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
-xmlns:xslt="output.xsl"
-xmlns:gs3="http://www.greenstone.org/gs3"
->
+  xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
+  xmlns:gslib="http://www.greenstone.org/skinning"
+  xmlns:java="http://xml.apache.org/xslt/java"
+  xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
+  xmlns:xalan="http://xml.apache.org/xalan"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xslt="output.xsl"
+  xmlns:gs3="http://www.greenstone.org/gs3"
+  >
 
-<xsl:output method="xml"/>
+  <xsl:output method="xml"/>
+
+  <xsl:template match="/">
+
+    <xsl:for-each select="/skinAndLibraryXsl/skinXsl/xsl:stylesheet">
+      
+      <!-- produce an exact copy of skin stylesheet, with gslib nodes expanded. -->
+      <xsl:variable name="element-name" select="name()"/>
+      <xsl:element name="{$element-name}">
+	<xsl:for-each select="@*">
+	  <xsl:variable name="attribute-name" select="name()"/>
+	  <xsl:attribute name="{$attribute-name}">
+	    <xsl:value-of select="."/>
+	  </xsl:attribute>
+	</xsl:for-each>
+	
+	<!-- merge the attributes of the library stylesheet -->
+	<xsl:for-each select="/skinAndLibraryXsl/libraryXsl/xsl:stylesheet/@*">
+	  <xsl:variable name="attribute-name" select="name()"/>
+	  <xsl:attribute name="{$attribute-name}">
+	    <xsl:value-of select="."/>
+	  </xsl:attribute>
+	</xsl:for-each>
+	
+	<xsl:call-template name="expand_gslib_elements" />
+	
+	<!-- add content of library to the skin stylesheet -->
+	<xsl:for-each select="/skinAndLibraryXsl/libraryXsl/xsl:stylesheet">
+	  <xsl:call-template name="expand_gslib_elements" />
+	</xsl:for-each>
+	
+
+      </xsl:element>
+      
+      
+    </xsl:for-each>
+  </xsl:template>
 
 
+  <!-- produce an exact copy of the current node, but expand and replace all elements belonging to the gslib namespace. -->
+  <xsl:template name="expand_gslib_elements">
 
 
-<xsl:template match="/">
-
-
-
-
-	<xsl:for-each select="/skinAndLibraryXsl/skinXsl/xsl:stylesheet">
-	
-		<!-- produce an exact copy of skin stylesheet, with gslib nodes expanded. -->
-		<xsl:variable name="element-name" select="name()"/>
-     	<xsl:element name="{$element-name}">
-      		<xsl:for-each select="@*">
-       			<xsl:variable name="attribute-name" select="name()"/>
-       			<xsl:attribute name="{$attribute-name}">
-        			<xsl:value-of select="."/>
-       			</xsl:attribute>
-      		</xsl:for-each>
-		
-			<!-- merge the attributes of the library stylesheet -->
-			<xsl:for-each select="/skinAndLibraryXsl/libraryXsl/xsl:stylesheet/@*">
-       			<xsl:variable name="attribute-name" select="name()"/>
-       			<xsl:attribute name="{$attribute-name}">
-        			<xsl:value-of select="."/>
-       			</xsl:attribute>
-      		</xsl:for-each>
-			
-     		 <xsl:call-template name="expand_gslib_elements" />
-			 
-			 <!-- add content of library to the skin stylesheet -->
-			 <xsl:for-each select="/skinAndLibraryXsl/libraryXsl/xsl:stylesheet">
-			 	<xsl:call-template name="expand_gslib_elements" />
-			 </xsl:for-each>
-			 
-
-     	</xsl:element>
-	 
-		
-	</xsl:for-each>
-</xsl:template>
-
-
-<!-- produce an exact copy of the current node, but expand and replace all elements belonging to the gslib namespace. -->
-<xsl:template name="expand_gslib_elements">
-
-
- <xsl:for-each select="*|text()">
-  <xsl:choose>
-  
-	
-    <!-- if node has gslib prefix, expand it into appropriate copy-of or call-template element -->
-    <xsl:when test="namespace-uri(.)=namespace::gslib">
-	
-		<xsl:variable name="name" select="local-name()"/>
-		<xsl:choose>
-		
-		<!-- if library contains a variable of this name, expand to it's value -->
-		<xsl:when test="/skinAndLibraryXsl/libraryXsl//xsl:variable[@name = $name]">
-			<xsl:element name="xsl:copy-of">
-				<xsl:attribute name="select">$<xsl:value-of select="local-name()" /></xsl:attribute>
-			</xsl:element>
-		</xsl:when>
-		
-		
-		<!-- if library contains a template of this name, expand to a call-template and pass attributes as parameters -->
-		<xsl:otherwise>
-			<xsl:element name="xsl:call-template">
-				<xsl:attribute name="name"> <xsl:value-of select="local-name()" /></xsl:attribute>
-				
-				<xsl:for-each select="@*">
-					<xsl:element name="xsl:with-param">
-						<xsl:attribute name="name"><xsl:value-of select="name()"/></xsl:attribute>
-						<xsl:call-template name="convert_attVal_to_valueOf" />
-					</xsl:element>					
-				</xsl:for-each>	
-			</xsl:element>
-		</xsl:otherwise>
-	
-		</xsl:choose>	
-    </xsl:when>
-
-    <xsl:when test="self::text()">
-     <xsl:value-of select="."/>
-    </xsl:when>
-
-		<!-- if a regular node v2 -->
-    <xsl:otherwise>
-     <xsl:variable name="element-name" select="name()"/>
-	 <xsl:variable name="element-namespace" select="namespace-uri()"/>
-     <xsl:element name="{$element-name}" namespace="{$element-namespace}">
-      <xsl:for-each select="@*">
-       <xsl:variable name="attribute-name" select="name()"/>
-       <xsl:attribute name="{$attribute-name}">
-        <xsl:value-of select="."/>
-       </xsl:attribute>
-      </xsl:for-each>
-      <xsl:call-template name="expand_gslib_elements" />
-     </xsl:element>
-    </xsl:otherwise>
+    <xsl:for-each select="*|text()">
+      <xsl:choose>
 	
 	
-  </xsl:choose>
- </xsl:for-each>
+	<!-- if node has gslib prefix, expand it into appropriate copy-of or call-template element -->
+	<xsl:when test="namespace-uri(.)=namespace::gslib">
+	  
+	  <xsl:variable name="name" select="local-name()"/>
+	  <xsl:choose>
+	    
+	    <!-- if library contains a variable of this name, expand to it's value -->
+	    <xsl:when test="/skinAndLibraryXsl/libraryXsl//xsl:variable[@name = $name]">
+	      <xsl:element name="xsl:copy-of">
+		<xsl:attribute name="select">$<xsl:value-of select="local-name()" /></xsl:attribute>
+	      </xsl:element>
+	    </xsl:when>
+	    
+	    
+	    <!-- if library contains a template of this name, expand to a call-template and pass attributes as parameters -->
+	    <xsl:otherwise>
+	      <xsl:element name="xsl:call-template">
+		<xsl:attribute name="name"> <xsl:value-of select="local-name()" /></xsl:attribute>
+		
+		<xsl:for-each select="@*">
+		  <xsl:element name="xsl:with-param">
+		    <xsl:attribute name="name"><xsl:value-of select="name()"/></xsl:attribute>
+		    <xsl:call-template name="convert_attVal_to_valueOf" />
+		  </xsl:element>					
+		</xsl:for-each>	
+	      </xsl:element>
+	    </xsl:otherwise>
+	    
+	  </xsl:choose>	
+	</xsl:when>
 
-</xsl:template>
+	<xsl:when test="self::text()">
+	  <xsl:value-of select="."/>
+	</xsl:when>
 
-<!-- converts an attribute value (the current node) into either a literal value or an <xsl:value-of> element -->
-<xsl:template name="convert_attVal_to_valueOf">
-
-	<xsl:choose>
-	<!-- if attribute is not literal (starts with a "{") -->
-		<xsl:when test="starts-with(string(), '&#123;')">
-			<xsl:element name="xsl:value-of">
-				<xsl:attribute name="disable-output-escaping">yes</xsl:attribute>
-				<xsl:attribute name="select"><xsl:value-of select="substring(string(),2,string-length()-2)"/></xsl:attribute>
-				</xsl:element>
-		</xsl:when>
-		<xsl:otherwise>
-			<xsl:value-of select="."/>
-		</xsl:otherwise>
-	</xsl:choose>
-</xsl:template>
-
-<xsl:template name="create_dummy_variables">
-	<xsl:for-each select="//*[namespace-uri()=namespace::gslib]">
-		<xsl:element name="xsl:variable">
-			<xsl:attribute name="name">
-				<xsl:value-of select="local-name()"/>
-			</xsl:attribute>
-		</xsl:element>	
-	</xsl:for-each>
-</xsl:template>
+	<!-- if a regular node v2 -->
+	<xsl:otherwise>
+	  <xsl:variable name="element-name" select="name()"/>
+	  <xsl:variable name="element-namespace" select="namespace-uri()"/>
+	  <xsl:element name="{$element-name}" namespace="{$element-namespace}">
+	    <xsl:for-each select="@*">
+	      <xsl:variable name="attribute-name" select="name()"/>
+	      <xsl:attribute name="{$attribute-name}">
+		<xsl:value-of select="."/>
+	      </xsl:attribute>
+	    </xsl:for-each>
+	    <xsl:call-template name="expand_gslib_elements" />
+	  </xsl:element>
+	</xsl:otherwise>
 	
 	
+      </xsl:choose>
+    </xsl:for-each>
+
+  </xsl:template>
+
+  <!-- converts an attribute value (the current node) into either a literal value or an <xsl:value-of> element -->
+  <xsl:template name="convert_attVal_to_valueOf">
+
+    <xsl:choose>
+      <!-- if attribute is not literal (starts with a "{") -->
+      <xsl:when test="starts-with(string(), '&#123;')">
+	<xsl:element name="xsl:value-of">
+	  <xsl:attribute name="disable-output-escaping">yes</xsl:attribute>
+	  <xsl:attribute name="select"><xsl:value-of select="substring(string(),2,string-length()-2)"/></xsl:attribute>
+	</xsl:element>
+      </xsl:when>
+      <xsl:otherwise>
+	<xsl:value-of select="."/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <xsl:template name="create_dummy_variables">
+    <xsl:for-each select="//*[namespace-uri()=namespace::gslib]">
+      <xsl:element name="xsl:variable">
+	<xsl:attribute name="name">
+	  <xsl:value-of select="local-name()"/>
+	</xsl:attribute>
+      </xsl:element>	
+    </xsl:for-each>
+  </xsl:template>
+  
+  
 </xsl:stylesheet>
