[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xml-cocoon-users
Subject:    Problems with internal redirection: empty output using a reader
From:       Sven Kitschke <kicke () web ! de>
Date:       2002-07-18 10:33:29
[Download RAW message or body]

Hello,

Configuration:
--------------
  win98, tomcat 4.0.4, cocoon 2.0.3 (binary dist), jdk 1.3.1_02

Problem:
--------
  I got problems with the internal redirection, readers ...
  In the most cases i get only empty output if I use a
  reader in conjunction with internal redirection.
  I've tried to produce a simple test case, but i'm not
  quite sure, the error is not produced always - I'm
  a little bit confused.

  <map:match pattern="hello1.html">
   <map:read mime-type="text/html" src="cocoon:/hello.html"/>
  </map:match>

Question:
---------
  Is it known? Have I something missed? A bug?

Workaround:
-----------
  Use a generator-serializer combination instead.

  <map:match pattern="hello2.html">
   <map:generate src="cocoon:/hello.html"/>
   <map:serialize />
  </map:match>


Testcase (dropped into mount/fail):
-----------------------------------
  hello-page.xml (from docs/samples)
  simple-page2html.xsl (from stylesheets/page)
  sitemap.xmap (attached)

In detail:
----------
If I call
http://localhost:8080/cocoon/mount/fail/hello2.html or
http://localhost:8080/cocoon/mount/fail/hello.html
there are never problems.

But if I call
http://localhost:8080/cocoon/mount/fail/hello1.html
often or in most cases i get an empty output!

I have tested (stopped tomcat, deleted work and restarted tomcat):
  compiled and interpreted sitemap,
  change default generator "file-no-label" to "file" and back -
  sometimes with success,
  deleted the browser cache,
  and so on, and on ...
Ooops:
  copying and touching hello-page.xml: works, works not, works, ...
Can this be? OK. I will test it.


HTH and thanks in advance, Sven.

["simple-page2html.xsl" (text/xml)]

<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:param name="view-source"/>

  <xsl:template match="page">
   <html>
    <head>
     <title>
      <xsl:value-of select="title"/>
     </title>
    </head>
    <body bgcolor="white" alink="red" link="blue" vlink="blue">
     <xsl:apply-templates/>
    </body>
   </html>
  </xsl:template>

  <xsl:template match="title">
   <h2 style="color: navy; text-align: center">
      <xsl:if test="not($view-source)">
         <xsl:apply-templates/>
      </xsl:if>     
      <xsl:if test="$view-source">
      <A>
         <xsl:attribute name="HREF">../view-source?filename=/<xsl:value-of \
select="$view-source"/></xsl:attribute>  <xsl:attribute \
name="TARGET">_blank</xsl:attribute>  <xsl:apply-templates/>
      </A>
      </xsl:if>     
   </h2>
  </xsl:template>

  <xsl:template match="para">
   <p align="left">
    <i><xsl:apply-templates/></i>
   </p>
  </xsl:template>


  <xsl:template match="@*|node()" priority="-2"><xsl:copy><xsl:apply-templates \
select="@*|node()"/></xsl:copy></xsl:template>  <xsl:template match="text()" \
priority="-1"><xsl:value-of select="."/></xsl:template>

</xsl:stylesheet>


["sitemap.xmap" (text/xml)]

<?xml version="1.0" encoding="ISO-8859-1"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
	<!-- =========================== Components ================================ -->
	<map:components>
		<map:generators default="file-no-label">
			<map:generator name="file" logger="sitemap.generator.file" 
				src="org.apache.cocoon.generation.FileGenerator" pool-max="32" pool-min="8" \
pool-grow="4"/>  <map:generator name="file-no-label" logger="sitemap.generator.file" 
				src="org.apache.cocoon.generation.FileGenerator" pool-max="32" pool-min="8" \
pool-grow="4"/>  </map:generators>
		<map:transformers default="xslt">
			<map:transformer logger="sitemap.transformer.xslt" name="xslt" pool-grow="2" \
pool-max="32" pool-min="8" 				  \
src="org.apache.cocoon.transformation.TraxTransformer">  \
<use-request-parameters>false</use-request-parameters>  \
<use-browser-capabilities-db>false</use-browser-capabilities-db>  \
<use-deli>false</use-deli>  </map:transformer>
		</map:transformers>
		<map:readers default="resource">
			<map:reader logger="sitemap.reader.resource" name="resource" pool-max="32" \
src="org.apache.cocoon.reading.ResourceReader"/>  </map:readers>
		<map:serializers default="html">
			<map:serializer logger="sitemap.serializer.html" mime-type="text/html" name="html" \
pool-grow="4" pool-max="32" pool-min="4" 		  \
src="org.apache.cocoon.serialization.HTMLSerializer">  \
<buffer-size>1024</buffer-size>  </map:serializer>
		</map:serializers>
		<map:matchers default="wildcard">
			<map:matcher logger="sitemap.matcher.wildcard" name="wildcard" \
src="org.apache.cocoon.matching.WildcardURIMatcher"/>  </map:matchers>
	</map:components>
	<!-- =========================== Pipelines ================================= -->
	<map:pipelines>
		<map:pipeline>
			<map:match pattern="hello.html">
				<map:generate  src="hello-page.xml" />
				<map:transform src="simple-page2html.xsl"/>
				<map:serialize/>
			</map:match>
			<map:match pattern="hello1.html">
				<map:read mime-type="text/html" src="cocoon:/hello.html"/>
			</map:match>
			<map:match pattern="hello2.html">
				<map:generate src="cocoon:/hello.html"/>
				<map:serialize /> 
			</map:match>

		</map:pipeline>
	</map:pipelines>
</map:sitemap>


["hello-page.xml" (text/xml)]

<?xml version="1.0"?>

<!-- CVS: $Id: hello-page.xml,v 1.2 2002/02/09 06:21:57 vgritsenko Exp $ -->

<!DOCTYPE page [
 <!ELEMENT page (title?, content)>
 <!ELEMENT title (#PCDATA)>
 <!ELEMENT content (para+)>
 <!ELEMENT para (#PCDATA)>
]>

<page>
 <title>Hello</title>
 <content>
  <para>This is my first Cocoon page!</para>
 </content>
</page>



---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic