cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernhard Huber" <berni_hu...@a1.net>
Subject Ant: JspGenerator and Encoding
Date Tue, 11 Dec 2001 18:51:00 GMT
Hi, 
you might try to work around in you jsp like that, encoding
non-ascii chars to xml #&NNN; form:

<%
String s1 = "\u041d\u0430\u0433\u043b\u0430\u0432\u043d\u0443\u044e";
String s2 = "ÄÜÖ";
%>

<%=encode(s1)%>
<%=encode(s2)%>

<%!
  String encode( String s ) {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < s.length(); i++ ) {
      char c = s.charAt(i);
      sb.append( "&#" ).append( (int)c ).append(";");
    }
    return sb.toString();
  }
%>



Huber Bernhard, email: berni.huber@a1.net, homepage:
members.a1.net/berni_huber/index.html



----- Ursprüngliche Nachricht -----
Von: Peter Schwenke <peter@bluetoad.com.au>
Datum: Dienstag, Dezember 11, 2001 6:23
Betreff: JspGenerator and Encoding

> 
> If I save the following in a file as iso-8859-1
> 
> <?xml version="1.0" encoding="iso-8859-1"?>
> 
> <page>
> <test>
> T-t testing 1-2-3!
> Günther
> check 1-2
> </test>
> </page>
> 
> and run it through xerces using a sample test program where the guts
> contains 
> 
> 
>         SAXParserFactory factory = SAXParserFactory.newInstance();
>         SAXParser parser = factory.newSAXParser();
>         DefaultHandler handler = new DefaultHandler()/* custom 
> handler class */;
>         parser.parse(xmlFile, handler);
> 
> I don't have any problems.  If I remove the encoding I get 
> 
> An invalid XML character (Unicode: 0xfc) was found in the element 
> content of the document.
> org.xml.sax.SAXParseException: An invalid XML character (Unicode: 
> 0xfc) was found in the element content of the document.
>        at 
> org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1016)
       at
org.apache.xerces.framework.XMLDocumentScanner.reportFatalXMLError(XMLDocumentScanner.java:643)
>        at 
>
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1355)
       at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:380)
>        at 
> org.apache.xerces.framework.XMLParser.parse(XMLParser.java:908)    
>    at javax.xml.parsers.SAXParser.parse(SAXParser.java:374)
>        at javax.xml.parsers.SAXParser.parse(SAXParser.java:264)
>        at DoParse.main(DoParse.java:18)
> 
> as expected
> 
> 
> I have the following entry in my sitemap
> 
>   <map:match pattern="newcec/*">
>    <map:generate type="jsp-with-params" 
> src="/docs/samples/newcec/{1}.jsp"/>    <map:transform 
> src="stylesheets/newcec.xsl"/>    <map:serialize type="html"/>
>    <map:handle-errors>
>      <map:transform src="stylesheets/system/error2html.xsl"/>
>      <map:serialize status-code="500"/>
>    </map:handle-errors>
>   </map:match>
> 
> where
> 
>   <map:generator  name="jsp-with-params"         
> src="org.apache.cocoon.generation.JspGenerator">    <use-request-
> parameters>true</use-request-parameters>
>    <encoding>iso-8859-1</encoding>
>   </map:generator>
> 
> I tried with and without this.
> 
> In the stylesheet I do
> 
> <?xml version="1.0" encoding="iso-8859-1"?>
> 
> JSP pages work fine with this until the data has a character with an
> umlaut or something.  The error is
> 
> Original exception : org.xml.sax.SAXParseException: An invalid XML 
> character (Unicode: 0xfc) was found in the element content of the 
> document.        at 
> org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1196)
       at
org.apache.xerces.framework.XMLDocumentScanner.reportFatalXMLError(XMLDocumentScanner.java:588)
>        at 
>
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1304)
       at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
>        at 
> org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1081)   
>     at 
>
org.apache.cocoon.components.parser.JaxpParser.parse(JaxpParser.java:100)
       at
org.apache.cocoon.generation.JspGenerator.generate(JspGenerator.java:80)
>        at 
>
org.apache.cocoon.components.pipeline.CachingEventPipeline.process(CachingEventPipeline.java:210)
       at
org.apache.cocoon.components.pipeline.CachingStreamPipeline.process(CachingStreamPipeline.java:359)
>        at 
>
org.apache.cocoon.www.sitemap_xmap.wildcardMatchN4003E0(sitemap_xmap.java:5325)
       at org.apache.cocoon.www.sitemap_xmap.process(sitemap_xmap.java:2779)
>        at 
> org.apache.cocoon.www.sitemap_xmap.process(sitemap_xmap.java:2420) 
>       at org.apache.cocoon.sitemap.Handler.process(Handler.java:163)
>        at org.apache.cocoon.sitemap.Manager.invoke(Manager.java:114)
>        at org.apache.cocoon.Cocoon.process(Cocoon.java:514)
>        at 
>
org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:592)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
>        at 
>
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
       at org.apache.tomcat.core.Handler.service(Handler.java:286)
>        at 
> org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
       at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
>        at 
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
       at
org.apache.tomcat.service.connector.Ajp13ConnectionHandler.processConnection(Ajp13ConnectionHandler.java:160)
>        at 
>
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
       at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
>        at java.lang.Thread.run(Thread.java:484)
> 
> 
> Very similar to that generated by removing the encoding in the xerces
> example.  It is as if the encoding in the xml statement is not getting
> through.  I have tried many different things like the encoding tag I
> saw in one message, putting in the appropriate META tag etc etc
> 
> Does anyone have any ideas on how I can resolve this?
> 
> I have searched and searched through the archives and can't resolve
> this issue.
> 
> 
>                                                                Thanks
>                                                                
> ...Peter
> -------------------------------------------------------------------
> --
> Please check that your question has not already been answered in the
> FAQ before posting. <" 
> target="l">http://xml.apache.org/cocoon/faqs.html>
> To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail: <cocoon-users-help@xml.apache.org>
> 
> 


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

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


Mime
View raw message