org.apache.cocoon.generation
Class RequestAttributeGenerator
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.xml.AbstractXMLProducer
org.apache.cocoon.generation.AbstractGenerator
org.apache.cocoon.generation.ServiceableGenerator
org.apache.cocoon.generation.RequestAttributeGenerator
- All Implemented Interfaces:
- Disposable, Generator, LogEnabled, Poolable, Recyclable, Serviceable, SitemapModelComponent, XMLProducer
- public class RequestAttributeGenerator
- extends ServiceableGenerator
The RequestAttributeGenerator
is a class that reads XML from a
request attribute and generates SAX Events.
The response encoding is taken as the encoding of the xml-data.
- Version:
- CVS $Id: RequestAttributeGenerator.java 30941 2004-07-29 19:56:58Z vgritsenko $
- Author:
- Kinga Dziembowski, Bernhard Huber
- Cocoon.sitemap.component.label:
- content
- Cocoon.sitemap.component.logger:
- sitemap.generator.req-attr
- Cocoon.sitemap.component.name:
- req-attr
- Cocoon.sitemap.component.parameter:
- attribute-name
type="String"
description="Specifies name of request attribute holding xml data. This xml data will be sent into the cocoon pipeline."
required="no"
default="org.apache.cocoon.xml-data"
Fields inherited from interface org.apache.cocoon.generation.Generator |
ROLE |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
REQUEST_ATTRIBUTE_NAME
public static final String REQUEST_ATTRIBUTE_NAME
- The config parameter for specifying name of the request attribute,
holding the name associated with the xml data, ie
attribute-name
.
- See Also:
- Constant Field Values
REQUEST_ATTRIBUTE_NAME_DEFAULT
public static final String REQUEST_ATTRIBUTE_NAME_DEFAULT
- The default name of the request attribute name, storing xml-data,
ie.
org.apache.cocoon.xml-data
.
- See Also:
- Constant Field Values
RequestAttributeGenerator
public RequestAttributeGenerator()
generate
public void generate()
throws SAXException,
ProcessingException
- Generate XML data out of request attribute, and send it into cocoon
pipeline.
- Throws:
SAXException
- Description of Exception
ProcessingException
- Description of Exception
getCharacterEncoding
protected String getCharacterEncoding(Response res,
String contentType)
- Content type HTTP header can contains character encodinf info
for ex. Content-Type: text/xml; charset=UTF-8
If the servlet is following spec 2.3 and higher the servlet API can be used to retrieve character encoding part of
Content-Type header. Some containers can choose to not unpack charset info - the spec is not strong about it.
in any case this method can be used as a latest resource to retrieve the passed charset value.
null
is returned.
It is very common mistake to send : Content-Type: text/xml; charset="UTF-8".
Some containers are not filtering this mistake and the processing results in exception..
The getCharacterEncoding() compensates for above mistake.
- Parameters:
contentType
- value associated with Content-Type HTTP header.res
- Description of Parameter
- Returns:
- The characterEncoding value
extractCharset
protected String extractCharset(String contentType,
int idx)
- Description of the Method
- Parameters:
contentType
- Description of Parameteridx
- Description of Parameter
- Returns:
- Description of the Returned Value
Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.