You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Art Spassky <ar...@dgma.donetsk.ua> on 2004/10/12 10:47:14 UTC

Problem with StreamGenerator

Hi all.

Can someoneb help me with my problem.
I am using cocoon-2.1.5.1.
I would like to use StreamGenerator for automatical generating documents
from uploaded files.
everything works well but I found problem with encoding.
When I upload xml file with encoding UTF-8 and transform it. Output file
contains irregular data.

Thank you for help in advance.

UploadForm.xml

<?xml version="1.0" encoding="Windows-1251"?>
<html>
<meta name="Content-Type" Value="text/html;charset=UTF-8"/>
<page>
 <title></title>
 <content>
 Привет
 <form name="UploadForm" method="post" action="submit"
enctype="multipart/form-data">
  <input type="file" name="Foo"/>
  <input id="submit1" name="submit1" type="submit" value="Submit"/>
 </form>
 </content>
</page>
</html>

extract from xslt file

<?xml version="1.0" encoding="Windows-1251"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 version="1.0">
<xsl:output encoding="UTF-8" indent="yes" method="xml"/>
<xsl:template match="/">
.........
</xsl:template>
</xsl:stylesheet>

Extract from sitemap.xmap

 <map:match pattern="UploadForm.html">
     <map:generate src="UploadForm.xml"/>
     <map:serialize/>
 </map:match>

 <map:match pattern="submit">
  <map:act type="">
       <map:parameter name="Cache-Control" value="max-age=0"/>
      <map:generate type="stream">
         <map:parameter name="form-name" value="Foo"/>
      </map:generate>
     <map:serialize type="xml"/>
  </map:act>
 </map:match>


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


Re: Problem with StreamGenerator

Posted by Art Spassky <ar...@dgma.donetsk.ua>.
With UTF-8 I have the same result.

I think the problem may be in how servlet container handle uploaded files.
I change encoding in web.xml but have the same result.

may be Jetty is not perfect servlet container or it is a bug.

Thank you once more for reply.

----- Original Message -----
From: "Volkm@r" <pl...@arcor.de>
To: <us...@cocoon.apache.org>
Sent: Tuesday, October 12, 2004 1:54 PM
Subject: Re: Problem with StreamGenerator


> Art Spassky wrote:
> > Hi all.
> >
> > Can someoneb help me with my problem.
> > I am using cocoon-2.1.5.1.
> > I would like to use StreamGenerator for automatical generating documents
> > from uploaded files.
> > everything works well but I found problem with encoding.
> > When I upload xml file with encoding UTF-8 and transform it. Output file
> > contains irregular data.
> >
> > Thank you for help in advance.
> >
> > UploadForm.xml
> >
> > <?xml version="1.0" encoding="Windows-1251"?>
> > <html>
> > <meta name="Content-Type" Value="text/html;charset=UTF-8"/>
>
> So you have
>
> 1. An XML declaration saying "Windows-1251"
> 2. A meta hack saying "UTF-8"
>
> Both should be the same and both *must* be in accordance with the
> charset info of the HTTP response header. As you are obviously using
> Cyrillic, you'd better chose the XML standard encoding which is UTF-8.
>
> Check the mime-type attribute of your HTML serializer to be
>
>     mime-type="text/html; charset=utf-8"
>
> so that it will put the correct header.
> --
> Volkm@r
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>


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


Re: Problem with StreamGenerator2

Posted by Art Spasky <ar...@dgma.donetsk.ua>.
> It perfectly works. But what can we use it for? Just only for viewing
> uploaded files?
Not only for that. You can organize Service to translate Xml files from one
schema to another.

Do you have ICQ? If you have, please send me on my e-mail


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


Re: Problem with StreamGenerator2

Posted by "Volkm@r" <pl...@arcor.de>.
Art Spassky wrote:
> Thank you very much.
> You help me a lot. 
> I found useful web page
> http://wiki.apache.org/cocoon/RequestParameterEncoding
> 
> The problem is solved !!!

I've also played around with the sample from
   "http://localhost:8080/cocoon/samples/stream/uploadfile"
but couldn't find anything wrong. It turned out that 
RequestParameterEncoding didn't need any changes.

Just download both files from here and put them into an empty mountable 
subdirectory. It's Cocoon's sample in a very simplified form.

   http://home.arcor.de/plsdontreply/streamupload/

It perfectly works. But what can we use it for? Just only for viewing 
uploaded files?
-- 
Volkm@r


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


Re: Problem with StreamGenerator2

Posted by Art Spassky <ar...@dgma.donetsk.ua>.
Thank you very much.
You help me a lot. 
I found useful web page
http://wiki.apache.org/cocoon/RequestParameterEncoding

The problem is solved !!!

----- Original Message ----- 
From: "Volkm@r" <pl...@arcor.de>
To: <us...@cocoon.apache.org>
Sent: Tuesday, October 12, 2004 4:43 PM
Subject: Re: Problem with StreamGenerator2


> Art Spassky wrote:
> > I think it is a bug. Or I am not completly understand encodings.
> > 
> > I use standard sample of StreamGenerator at
> > http://localhost:8888/samples/stream/uploadfile
> > 
> > I change its sitemap.xmap with the following
> > 
> > <map:components>
> >   <map:serializers default="html">
> >    <map:serializer name="html" mime-type="text/html; charset=UTF-8"
> >   src="org.apache.cocoon.serialization.HTMLSerializer">
> >      <encoding>UTF-8</encoding>
> >    </map:serializer>
> >   </map:serializers>
> > 
> > </map:components>
> > 
> > When I upload xml file without cyrilic symbols all works well. Problems
> > begin when I use them.
> 
> What about sending Cyrillic (or other utf-8) text in a simple form 
> field, does that work? If not you might read
> <http://www.mail-archive.com/users@cocoon.apache.org/msg19326.html>
> (please read the whole thread!) and
> <http://wiki.apache.org/cocoon/RequestParameterEncoding>
> 
> Sorry if this wouldn't help either. It is about form encoding but 
> uploading files shouldn't be too far away from that.
> -- 
> Volkm@r
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 


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


Re: Problem with StreamGenerator2

Posted by "Volkm@r" <pl...@arcor.de>.
Art Spassky wrote:
> I think it is a bug. Or I am not completly understand encodings.
> 
> I use standard sample of StreamGenerator at
> http://localhost:8888/samples/stream/uploadfile
> 
> I change its sitemap.xmap with the following
> 
> <map:components>
>   <map:serializers default="html">
>    <map:serializer name="html" mime-type="text/html; charset=UTF-8"
>   src="org.apache.cocoon.serialization.HTMLSerializer">
>      <encoding>UTF-8</encoding>
>    </map:serializer>
>   </map:serializers>
> 
> </map:components>
> 
> When I upload xml file without cyrilic symbols all works well. Problems
> begin when I use them.

What about sending Cyrillic (or other utf-8) text in a simple form 
field, does that work? If not you might read
<http://www.mail-archive.com/users@cocoon.apache.org/msg19326.html>
(please read the whole thread!) and
<http://wiki.apache.org/cocoon/RequestParameterEncoding>

Sorry if this wouldn't help either. It is about form encoding but 
uploading files shouldn't be too far away from that.
-- 
Volkm@r


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


Re: Problem with StreamGenerator2

Posted by Art Spassky <ar...@dgma.donetsk.ua>.
I think it is a bug. Or I am not completly understand encodings.

I use standard sample of StreamGenerator at
http://localhost:8888/samples/stream/uploadfile

I change its sitemap.xmap with the following

<map:components>
  <map:serializers default="html">
   <map:serializer name="html" mime-type="text/html; charset=UTF-8"
  src="org.apache.cocoon.serialization.HTMLSerializer">
     <encoding>UTF-8</encoding>
   </map:serializer>
  </map:serializers>

</map:components>

When I upload xml file without cyrilic symbols all works well. Problems
begin when I use them.


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


Re: Problem with StreamGenerator

Posted by "Volkm@r" <pl...@arcor.de>.
Art Spassky wrote:
> Hi all.
> 
> Can someoneb help me with my problem.
> I am using cocoon-2.1.5.1.
> I would like to use StreamGenerator for automatical generating documents
> from uploaded files.
> everything works well but I found problem with encoding.
> When I upload xml file with encoding UTF-8 and transform it. Output file
> contains irregular data.
> 
> Thank you for help in advance.
> 
> UploadForm.xml
> 
> <?xml version="1.0" encoding="Windows-1251"?>
> <html>
> <meta name="Content-Type" Value="text/html;charset=UTF-8"/>

So you have

1. An XML declaration saying "Windows-1251"
2. A meta hack saying "UTF-8"

Both should be the same and both *must* be in accordance with the 
charset info of the HTTP response header. As you are obviously using 
Cyrillic, you'd better chose the XML standard encoding which is UTF-8.

Check the mime-type attribute of your HTML serializer to be

    mime-type="text/html; charset=utf-8"

so that it will put the correct header.
-- 
Volkm@r


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