You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Derek Hohls <dh...@csir.co.za> on 2006/05/21 10:55:33 UTC

Filter Transformer generating non-XML

I am running Cocoon 2.1.5 and JDK 1.5.

I have a SQL Transformer that seems to be working just fine;
however, when I pass the results through the Filter Transformer
I seem to get garbage out:

Sitemap:

<map:match pattern="db/list-*">
  <map:generate src="queries/list/{1}.xml" type="jx" label="debug">
	  <use-request-parameters>true</use-request-parameters>
  </map:generate> 
  <map:transform type="sql" label="debug1">
  <map:parameter name="use-connection" value="my_user"/>
  <map:parameter name="show-nr-of-rows" value="true"/> 
  <map:parameter name="clob-encoding" value="UTF-8"/> 
  </map:transform>
  <map:transform type="filter" label="debug2">
  <map:parameter name="element-name" value="row"/>
  <map:parameter name="count" value="50"/>
  <map:parameter name="blocknr" value="1"/>
  </map:transform>
  <map:serialize type="html"/>
</map:match>	

At "debug1" stage I have:

<page xmlns:sq2="http://apache.org/cocoon/SQL/2.0" xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
 <rowset xmlns="http://apache.org/cocoon/SQL/2.0" nrofrows="3" name="projectlist">
 <row>
  <projno>1</projno> 
  <title>Joint study</title> 
  <startdate>2001-04-01</startdate> 
  <enddate>2004-06-30</enddate> 
	<rowset nrofrows="3" name="clientlist">
	<row>
	<client>Company A</client> 
	</row>
	<row>
	<client>Company B</client> 
	</row>
	<row>
	<client>Company C</client> 
	</row>
	</rowset>
 </row>
 <row>
  <projno>2</projno> 
  <title>TESTing</title> 
  <startdate>2004-09-17</startdate> 
  <enddate>2007-05-19</enddate> 
  <rowset nrofrows="0" name="clientlist" /> 
 </row>
 <row>
  <projno>3</projno> 
  <title>DUMMY</title> 
  <startdate>2006-05-20</startdate> 
  <enddate>2006-05-20</enddate> 
  <rowset nrofrows="0" name="clientlist" /> 
 </row>
 </rowset>
</page>

which is what is expected from the database.

And at "debug2" stage I have:

<page xmlns:sq2="http://apache.org/cocoon/SQL/2.0" xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
  <rowset xmlns="http://apache.org/cocoon/SQL/2.0" nrofrows="3" name="projectlist">
  <block id="1"></block>
  </rowset>
  </row>
  </block>
  </rowset>
  </row>
  </block>
  </rowset>
  </row>
  </rowset>
</page>

which as can be seen is not even gramatically correct XML?

Any ideas as to how to make this work properly?

Thanks
Derek

-- 
This message is subject to the CSIR's copyright, terms and conditions and
e-mail legal notice. Views expressed herein do not necessarily represent the
views of the CSIR.
 
CSIR E-mail Legal Notice
http://mail.csir.co.za/CSIR_eMail_Legal_Notice.html 
 
CSIR Copyright, Terms and Conditions
http://mail.csir.co.za/CSIR_Copyright.html 
 
For electronic copies of the CSIR Copyright, Terms and Conditions and the CSIR
Legal Notice send a blank message with REQUEST LEGAL in the subject line to
HelpDesk@csir.co.za.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.


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


RE: Filter Transformer generating non-XML

Posted by Andrew Stevens <at...@hotmail.com>.
>From: "Derek Hohls" <dh...@csir.co.za>
>Date: Sun, 21 May 2006 10:55:33 +0200
>
>I am running Cocoon 2.1.5 and JDK 1.5.
>
>I have a SQL Transformer that seems to be working just fine;
>however, when I pass the results through the Filter Transformer
>I seem to get garbage out:
...
>At "debug1" stage I have:
>
><page xmlns:sq2="http://apache.org/cocoon/SQL/2.0" 
>xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
>  <rowset xmlns="http://apache.org/cocoon/SQL/2.0" nrofrows="3" 
>name="projectlist">
>  <row>
>   <projno>1</projno>
>   <title>Joint study</title>
>   <startdate>2001-04-01</startdate>
>   <enddate>2004-06-30</enddate>
>	<rowset nrofrows="3" name="clientlist">
>	<row>
>	<client>Company A</client>
>	</row>
>	<row>
>	<client>Company B</client>
>	</row>
>	<row>
>	<client>Company C</client>
>	</row>
>	</rowset>
>  </row>
>  <row>
>   <projno>2</projno>
>   <title>TESTing</title>
>   <startdate>2004-09-17</startdate>
>   <enddate>2007-05-19</enddate>
>   <rowset nrofrows="0" name="clientlist" />
>  </row>
>  <row>
>   <projno>3</projno>
>   <title>DUMMY</title>
>   <startdate>2006-05-20</startdate>
>   <enddate>2006-05-20</enddate>
>   <rowset nrofrows="0" name="clientlist" />
>  </row>
>  </rowset>
></page>
>
>which is what is expected from the database.

Hmm... nested rowsets.  Presumably using nested queries and the sql:ancestor 
value tag?  Perfectly okay in itself, but I suspect that's what confusing 
the filter transformer; it probably can't tell the two types of row apart, 
and since it's just looking for the specified element name "row" my guess is 
it'll start recording when it reaches the start of an outer row but end 
recording when it sees the end of the first inner row.  After that it just 
copies elements until it hits another opening row tag, which I think would 
produce something like you're getting when it reaches the end of the outer 
row.

>Any ideas as to how to make this work properly?

Add an extra XSL transformer between the SQL & filter transformers, to 
change the rowset/row elements into different elements (e.g. 
projects/project & clients/client) for the inner and outer rows.  That way 
the filter transformer won't get the two confused.


Andrew.



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