[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.8

XSLT Error

Asked by FirePits in Extensible Stylesheet Language Transformation (XSLT)

Tags: XSL, XSLT, XML, xsl:template

I am receiving an error when trying to transform an xml doc with the xsl below. The error message states:

xsl:template is not allowed in this position in the stylesheet!

Any help in identifying the error and a possible resolution is appreciated.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
<xsl:template name="result">
 
	<div class="searchResult">
		<span class="date">
<!-- The example XML doesn't contain date fields; the values would go here, but this placeholder is here instead. -->
			<xsl:text> </xsl:text>
		</span>
		<h3>
			<xsl:choose>
				<xsl:when test="fields/field[@name='ext']/value = 'pdf'">
					<a class="pdf">
						<xsl:attribute name="href"><xsl:value-of select="reference"/></xsl:attribute>
						<xsl:value-of select="title" disable-output-escaping="yes"/>
					</a>
				</xsl:when>
				<xsl:otherwise>
					<a>
						<xsl:attribute name="href"><xsl:value-of select="reference"/></xsl:attribute>
						<xsl:value-of select="title" disable-output-escaping="yes"/>
					</a>
				</xsl:otherwise>
			</xsl:choose>
		</h3>
		<p>
						<xsl:template match="summary">
				<xsl:call-template name="globalReplace">
					<xsl:with-param name="outputString" select="summary"/>
					<xsl:with-param name="target" select="'&lt;br&gt;'"/>
					<xsl:with-param name="replacement" select="''"/>
				</xsl:call-template>
			</xsl:template>
		</p>
		<a>
			<xsl:attribute name="href"><xsl:value-of select="reference"/></xsl:attribute>
			<xsl:value-of select="reference"/>
		</a>
	</div>
</xsl:template>
 
 
<!-- Template to replace a text substring. --> 
<xsl:template name="globalReplace">
	<xsl:param name="outputString"/>
	<xsl:param name="target"/>
	<xsl:param name="replacement"/>
	<xsl:choose>
		<xsl:when test="contains($outputString,$target)">
			<xsl:value-of select=
				"concat(substring-before($outputString,$target),
				$replacement)"
				disable-output-escaping="yes"/>
			<xsl:call-template name="globalReplace">
				<xsl:with-param name="outputString" 
					select="substring-after($outputString,$target)"/>
				<xsl:with-param name="target" select="$target"/>
				<xsl:with-param name="replacement" 
					select="$replacement"/>
			</xsl:call-template>
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="$outputString" disable-output-escaping="yes"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>
 
 
<!--Template to generate a URL query string composed of parameters passed to the current search.
	 Optional parameter "exclude" is passed to exclude a specific parameter from being appended -->
<xsl:template name="paramString">
	<xsl:param name="exclude" select=""/>
	<xsl:for-each select="/searchResponse/query/param">
		<xsl:if test="$exclude != ./@name">
			<xsl:if test="position() &gt; 1">&amp;</xsl:if>
			<xsl:value-of select="concat(@name,'=',@encoded)"/>
		</xsl:if>
	</xsl:for-each>
</xsl:template>
 
 
<!--Pagination template - displays a single page number (linked unless it's the currently displayed page) and calls itself to display the next page.-->
<xsl:template name="pagination">
	<xsl:param name="min" select="1"/>
	<xsl:param name="max" select="100"/>
	<xsl:param name="pageStart" select="1"/>
	<xsl:param name="pageEnd" select="10"/>
	<xsl:param name="constResultsPerPage" select="10"/>
	<xsl:param name="pageNumber" select="1"/>
	<xsl:param name="nextPagenumber" select="1"/>
	<xsl:param name="constURL"/>
 
	<li>
		<xsl:choose>
			<xsl:when test="$pageNumber != $nextPagenumber">
				<a>
				<xsl:attribute name="href"><xsl:value-of select="$constURL"/>&amp;start=<xsl:value-of select="$min"/></xsl:attribute>
				<xsl:value-of select="$nextPagenumber"/>
				</a> 
			</xsl:when>
			<xsl:otherwise>
				<xsl:attribute name="class">active</xsl:attribute>
				<xsl:value-of select="$nextPagenumber"/> 
			</xsl:otherwise>
		</xsl:choose>
	</li>
 
	<xsl:if test="($min + $constResultsPerPage) &lt;= $max">
		<xsl:call-template name="pagination">
			<xsl:with-param name="min"><xsl:value-of select="$min + $constResultsPerPage"/></xsl:with-param>
			<xsl:with-param name="max"><xsl:value-of select="$max"/></xsl:with-param>
			<xsl:with-param name="pageEnd"><xsl:value-of select="$pageEnd"/></xsl:with-param>
			<xsl:with-param name="constResultsPerPage"><xsl:value-of select="$constResultsPerPage"/></xsl:with-param>
			<xsl:with-param name="pageNumber"><xsl:value-of select="$pageNumber"/></xsl:with-param>
			<xsl:with-param name="nextPagenumber"><xsl:value-of select="$nextPagenumber + 1"/></xsl:with-param>
			<xsl:with-param name="constURL"><xsl:value-of select="$constURL"/></xsl:with-param>
		</xsl:call-template>
	</xsl:if>
</xsl:template>
[+][-]09/03/09 04:57 PM, ID: 25256053Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09/03/09 05:30 PM, ID: 25256154Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/04/09 03:02 AM, ID: 25258014Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Extensible Stylesheet Language Transformation (XSLT)
Tags: XSL, XSLT, XML, xsl:template
Sign Up Now!
Solution Provided By: Gertone
Participating Experts: 2
Solution Grade: A
 
[+][-]09/07/09 11:06 AM, ID: 25276499Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/07/09 12:05 PM, ID: 25276765Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625