You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Kjell Arne Brødreskift <ka...@web-som-virker.no> on 2005/02/20 15:49:15 UTC

Trouble matching sql:block from FilterTransformer

I am using FilterTransformer to return portions of data from a database
search. It seems that the transformer returns the blocks as it should,
because I can match on the word 'block', which comes from the transformer.
If I do it returns a block with 5 rows as defined in the stylesheet and
shows a table without the ability to go to First, Next, Previous and Last
block as the proper match (below) should.

The example I'm trying to run is based on Cocoon 2.0.3 and I'm running 2.1.6

I'm not able to see anything wrong here, but perhaps some of you have been
trying something similar? 


Kjell Arne





This is the template match from ticket-review.xsl:

	<xsl:template match="sql:block[count(sql:row) > 0]">


Here is the pipeline:

	<map:match pattern="ticket-review">
		<map:generate type="file" src="content/ticket-review.xml"/>
		<map:transform type="sql">
			<map:parameter name="use-connection" value="abc"/>
		</map:transform>
		<map:act type="request">
			<map:parameter name="parameters" value="true"/>
			<map:parameter name="default.page" value="1"/>
			<map:transform type="filter" label="raw">
				<map:parameter name="element-name"
value="row"/>
				<map:parameter name="count" value="5"/>
				<map:parameter name="blocknr"
value="{page}"/>
			</map:transform>
		</map:act>
		<map:transform type="xslt" src="style/ticket-review.xsl"/>
		<map:serialize type="html"/>
	</map:match>


And this is the ticket-review.xml:

	<?xml version="1.0"?>
	<page>
		<title>Trouble tickets</title>
		<content>
			<execute-query
xmlns="http://apache.org/cocoon/SQL/2.0">
				<query>
					select * from troubletickets 
					order by customer, ticket_opened
				</query>
			</execute-query>
		</content>
	</page>


This is the full stylesheet, ticket-review.xsl

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:sql="http://apache.org/cocoon/SQL/2.0">

	<xsl:template match="/page">
		<html>
			<head>
				<title><xsl:value-of
select="page-title"/></title>
			</head>
			<body bgcolor="white">
				<br/>
				<xsl:apply-templates/>
			</body>
		</html>
	</xsl:template>

	<xsl:template match="title">
		<h3><xsl:apply-templates/></h3>
	</xsl:template>

	<xsl:template match="sql:rowset">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="sql:block[count(sql:row) > 0]">
		<p>
			Page <xsl:value-of select="@sql:id"/> of
			<xsl:value-of
select="count(//sql:block)"/>:&#160;&#160;
			
			<xsl:if test="count(//sql:block) > 1">
				<xsl:if test="position() > 1">
					<a
href="ticket-review?page=1">First</a>
					&#160;
					<a>
						<xsl:attribute name="href">
							<xsl:text>
	
<![CDATA[ticket-review?page=]]>
							</xsl:text>
							<xsl:value-of
select="position() - 1"/>
						</xsl:attribute>
						Previous
					</a>
					&#160;
				</xsl:if>
				
				<xsl:if test="position() !=
count(//sql:block)">
					<a>
						<xsl:attribute name="href">
							<xsl:text>
	
<![CDATA[ticket-review?page=]]>
							</xsl:text>
							<xsl:value-of
select="position() + 1"/>
						</xsl:attribute>
						Next
					</a>
					&#160;
					
					<a>
						<xsl:attribute name="href">
							<xsl:text>
	
<![CDATA[ticket-review?page=]]>
							</xsl:text>
							<xsl:value-of
select="count(//sql:block)"/>
						</xsl:attribute>
						Last
					</a>
					&#160;
				</xsl:if>
			</xsl:if>
		</p>

		<table border="1">
			<xsl:apply-templates/>
		</table>	
	</xsl:template>
	
	<xsl:template match="sql:row">
		<tr>
			<xsl:for-each select="*">
				<td>
					<xsl:apply-templates/>
				</td>
			</xsl:for-each>
		</tr>
	</xsl:template>
	
</xsl:stylesheet>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org