cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alec Bickerton <alec.bicker...@net-m.ch>
Subject Re: HTML5 doctype from Cocoon 2.1?
Date Wed, 17 Nov 2010 10:17:26 GMT
In short, we need to modify the doctypes dynamically based on a particular device. For example
one might support xhtml
mobile profile 1.1 another only regular html.

Due to the way our app is constructed, this cannot really be handled in any other way.

Alec,

On 17/11/10 00:12, Martin Holmes wrote:
> Thanks Alec -- I think I might be able to manage an HTML5 serializer if
> I have a good example to work from. I'm puzzled about why you needed
> your custom serializer, though -- I've been able to serialize XHTML 1.1
> without problems, using the regular serializer configured just like
> yours below. 



> What does your dynamic serializer do that can't be done
> with a regular one?
> 
> Cheers,
> Martin
> 
> On 10-11-16 01:05 AM, Alec Bickerton wrote:
>> The code below is part of a seperate serialiizer class that extands
>> HTMLSerializer and implements SitemapModelComponent.
>> It's configered in the sitemap as shown.
>>
>> <map:serializer name="xhtml-flexible"
>> logger="sitemap.serializer.xhtml" mime-type="application/xhtml+xml;
>> charset=utf-8"
>> pool-grow="2" pool-max="64"     pool-min="2"
>> src="ch.example.cocoon.serializer.DynamicSerializer">
>>     <indent>yes</indent>
>>     <doctype-public>-//W3C//DTD XHTML 1.1//EN</doctype-public>
>>     <doctype-system>http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</doctype-system>
>>
>>     <encoding>UTF-8</encoding>
>> </map:serializer>
>>
>> Regards,
>> Alec
>>
>> On 15/11/10 17:09, Martin Holmes wrote:
>>> Hi there,
>>>
>>> Where exactly did you put this code? Did you implement your serializer
>>> as a separate class file, or have you modified the core Cocoon code?
>>>
>>> (I have no experience of customizing Cocoon itself, although I've
>>> written the odd class to implement custom sorting collations and to add
>>> functionality to XQuery code.)
>>>
>>> Cheers,
>>> Martin
>>>
>>> On 10-11-15 01:08 AM, Alec Bickerton wrote:
>>>> Hi,
>>>>
>>>> Just to throw in my 0.02c. At my current workplace we solved this
>>>> issue by implementing both a dynamic XML Serializer
>>>> and an HTML Serializer. We found that reconfiguring a the serializer
>>>> for each use while risky does work.
>>>>
>>>> Caveat: While this approach has been tested under light load. I cannot
>>>> say how it'll behave under heavy load, we're
>>>> still checking. YMMV.
>>>>
>>>>>      public void setup(SourceResolver resolver, Map objectModel,
>>>>> String src, Parameters par) {
>>>>>          String configxml = "";
>>>>>          String[] parameterNames = par.getNames();
>>>>>          for (int i = 0; i<   parameterNames.length; i++) {
>>>>>              String paramName = parameterNames[i];
>>>>>              String paramValue = par.getParameter(paramName, null);
>>>>>              if (!paramName.isEmpty()&&   paramValue != null)
>>>>>                  configxml += "<" + paramName +">" + paramValue
+"</"
>>>>> + paramName + ">";
>>>>>          }
>>>>>          if (configxml.length()>   0) {
>>>>>              configxml = "<settings>" + configxml +"</settings>";
//
>>>>> put settings around to make an 'xml'
>>>>>              try {
>>>>>                  DefaultConfigurationBuilder confBuilder = new
>>>>> DefaultConfigurationBuilder();
>>>>>                  ByteArrayInputStream stream = new
>>>>> ByteArrayInputStream(configxml.getBytes());
>>>>>                  Configuration conf = confBuilder.build(stream);
>>>>>                  /****
>>>>>                   * all these values are supported - see
>>>>> AbstractTextSerializer cdata-section-elements doctype-public
>>>>>                   * doctype-system encoding indent media-type method
>>>>> omit-xml-declaration standalone version
>>>>>                   ***************************************/
>>>>>                  super.configure(conf);
>>>>>              } catch (ConfigurationException e) {
>>>>>                  log.error("ConfigurationException: " +
>>>>> e.getLocalizedMessage(), e);
>>>>>              } catch (SAXException e) {
>>>>>                  log.error("SAXException: " + e.getLocalizedMessage(),
>>>>> e);
>>>>>              } catch (IOException e) {
>>>>>                  log.error("IOException: " +
>>>>> e.getLocalizedMessage(), e);
>>>>>              }
>>>>>          }
>>>>>      }
>>>>
>>>>
>>>> On 15/11/10 05:31, Jos Snellings wrote:
>>>>> Hi Martin,
>>>>>
>>>>> Do not know details, but it might help if you use the xsl:output
>>>>> element
>>>>> in your transformation.
>>>>> There is hope that it would not be overridden by the serializer.
>>>>>
>>>>> <xsl:output
>>>>> method="xml|html|text|name"
>>>>> version="string"
>>>>> encoding="string"
>>>>> omit-xml-declaration="yes|no"
>>>>> standalone="yes|no"
>>>>> doctype-public="string"
>>>>> doctype-system="string"
>>>>> cdata-section-elements="namelist"
>>>>> indent="yes|no"
>>>>> media-type="string"/>
>>>>>
>>>>> Cheers,
>>>>> Jos
>>>>>
>>>>>
>>>>> On 11/12/2010 05:17 PM, Martin Holmes wrote:
>>>>>> Hi there,
>>>>>>
>>>>>> Does anyone know how to configure a serializer for Cocoon 2.1 that
>>>>>> will output an HTML5 document? That means a minimal doctype that
>>>>>> looks
>>>>>> like this:
>>>>>>
>>>>>> <!DOCTYPE html>
>>>>>>
>>>>>> served as text/html.
>>>>>>
>>>>>> Cheers,
>>>>>> Ma

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


Mime
View raw message