You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Steve Conover <sc...@groundswell.net> on 2000/09/05 20:26:03 UTC

xsp architecture/style question regarding http params

Hi everyone,

I'm trying to figure out the cleanest way to represent request parameters in
my source xml document.  Right now they're just hard-coded into my xsp
document (request.getParameter("x")) and invisible to the content editor.
Should they be buried in the xsp (maybe it's not appropriate to represent
them in the source document?).

Here's an example of what I have right now.  I'm taking a get parameter
called "categoryid" in the xsp document, which determines what the current
category is.  

Here's the source:
<category levels-up="9999" levels-down="1" show-particular-file="true"/>
So my question is, from just looking at the source file one has no idea that
I'm pulling categoryid http variable...I thought about using the request
taglib but I don't want to introduce xsp processing in my source
document...I'm not even sure that's a viable alternative anyway.  I'd be
nice to have some sort of control that says this http parameter feeds into
this part of the document...is it possible?  suggestions?



Here's the corresponding xsp template (pretty long, but you see where I
reference the request parameter):
	<xsl:template match="category">
		<raw-category-results>
			<xsl:if test="@levels-up > 0">
				<parent-categories>
					<!-- note that there's actually no
way to control how many levels up of categories you get, it's either 0 or
all of them -->
					<connection:execute-query
id="parent-categories-query">
	           				<connection:statement>
							select catg_id as
categoryid, catg_name as name
							from doc_category_t
							connect by prior
catg_parent_id = catg_id start with catg_id=
								(select
catg_parent_id from doc_category_t where
catg_id=<xsp:expr>request.getParameter("categoryid")</xsp:expr>)
							order by catg_id
						</connection:statement>
	          			</connection:execute-query>
				</parent-categories>
			</xsl:if>
			
			<current-category>
				<connection:execute-query
id="current-category-query">
           				<connection:statement>
						select catg_id as
categoryid, catg_name as name
						from doc_category_t
						where
catg_id=<xsp:expr>request.getParameter("categoryid")</xsp:expr>
					</connection:statement>
          			</connection:execute-query>
				
				<xsl:if test="@show-files = 'true'">

					<connection:execute-query
id="current-category-document-query">
	           				<connection:statement>
							select d.doc_id,
d.name as filename, d.description, d.submit_date, 
	
d.expire_date, d.version, d.size_kb,
	
t.type_name as type,
	
s.status_name as status,
								   u.fname,
u.lname, u.empid as userid
							from document_t d,
doc_type_t t, doc_status_t s, employee_t u
							where 
								d.type_id =
t.type_id
								and
d.status_id = s.status_id
								and d.author
= u.empid
								and
d.catg_id=<xsp:expr>request.getParameter("categoryid")</xsp:expr>
							order by d.name,
d.version
						</connection:statement>
	          			</connection:execute-query>
				</xsl:if>
			</current-category>
			
			<xsl:if test="@levels-down = 1">
				<connection:execute-query
id="sub-categories-query">
           				<connection:statement>
						select catg_id as
categoryid, catg_name as name
						from doc_category_t
						where
catg_parent_id=<xsp:expr>request.getParameter("categoryid")</xsp:expr>
					</connection:statement>
          			</connection:execute-query>
			</xsl:if>
	</raw-category-results>
	</xsl:template>