cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <scher...@gmail.com>
Subject Re: svn commit: r1305128 - /cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/I18nTransformer.java
Date Tue, 03 Apr 2012 11:47:10 GMT
On 03/25/2012 10:58 PM, andreas@apache.org wrote:
> Author: andreas
> Date: Sun Mar 25 20:58:50 2012
> New Revision: 1305128
>
> URL: http://svn.apache.org/viewvc?rev=1305128&view=rev
> Log:
> Add parameters parse-xml and parse-namespace to the I18nTransformer. Allows to include
XML elements in I18n messages.
>
> Modified:
>      cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/I18nTransformer.java
>
> Modified: cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/I18nTransformer.java
> URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/I18nTransformer.java?rev=1305128&r1=1305127&r2=1305128&view=diff
> ==============================================================================
> --- cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/I18nTransformer.java
(original)
> +++ cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/I18nTransformer.java
Sun Mar 25 20:58:50 2012
> @@ -33,9 +33,9 @@ import java.util.Map;
>   import java.util.MissingResourceException;
>   import java.util.PropertyResourceBundle;
>   import java.util.ResourceBundle;
> +import java.util.ResourceBundle.Control;
>   import java.util.Set;
>   import java.util.StringTokenizer;
> -import java.util.ResourceBundle.Control;
>
>   import org.apache.cocoon.pipeline.SetupException;
>   import org.apache.cocoon.pipeline.caching.CacheKey;
> @@ -44,6 +44,7 @@ import org.apache.cocoon.pipeline.compon
>   import org.apache.cocoon.sax.AbstractSAXTransformer;
>   import org.apache.cocoon.sax.util.VariableExpressionTokenizer;
>   import org.apache.cocoon.sax.util.VariableExpressionTokenizer.TokenReceiver;
> +import org.apache.cocoon.sax.util.XMLUtils;
>   import org.apache.cocoon.xml.sax.ParamSAXBuffer;
>   import org.apache.cocoon.xml.sax.SAXBuffer;
>   import org.slf4j.Logger;
> @@ -577,6 +578,16 @@ public class I18nTransformer extends Abs
>       public static final String DEFAULT_ENCODING = "ISO-8859-1";
>
>       /**
> +     * If XML inside i18n messages shall be parsed.
> +     */
> +    public static final String PARAM_PARSE_XML = "parse-xml";
> +
> +    /**
> +     * The default namespace for XML elements inside messages. Defaults to http://www.w3.org/1999/xhtml.
> +     */
> +    public static final String PARAM_PARSE_NAMESPACE = "parse-namespace";
> +
> +    /**
>        * States of the transformer.
>        */
>       private enum TransformerState {
> @@ -717,6 +728,12 @@ public class I18nTransformer extends Abs
>
>       // Date and number elements and params formatting attributes with values.
>       private Map<String, String>  formattingParams;
> +
> +    // parse XML inside messages?
> +    private boolean parseXml;
> +
> +    // default namespace for XML inside messages
> +    private String parseNamespace;
>
>       /**
>        * Empty constructor, for usage with sitemap.
> @@ -806,6 +823,16 @@ public class I18nTransformer extends Abs
>
>           final String encoding = (String) (parameters.containsKey(PARAM_ENCODING)
>                   ? parameters.get(PARAM_ENCODING) : DEFAULT_ENCODING);
> +
> +        this.parseXml = parameters.containsKey(PARAM_PARSE_XML)
> +                ? Boolean.parseBoolean((String) parameters.get(PARAM_PARSE_XML))
> +                : false;
> +
> +        if (this.parseXml) {
> +            this.parseNamespace = parameters.containsKey(PARAM_PARSE_NAMESPACE)
> +                    ? (String) parameters.get(PARAM_PARSE_NAMESPACE)
> +                    : "http://www.w3.org/1999/xhtml";
> +        }
>

Hi Andi,

is there a reason why you did not exposed
- setParseXml(...)
- setParseNamespace(...)

I said it since now it not possible to use the parseXml without using 
the setup. This however is highly problematic since the first line is
if (parameters == null || !parameters.containsKey(PARAM_BUNDLE)) {
             return;
         }

Meaning if I do not pass the bundle the setup will simply stop however 
the parseXml is independent from the bundle and the rest of the setup.

So I would like to expose the setter and further move the 
parameters.containsKey(PARAM_BUNDLE) AFTER the parseXml routine in setup.

If you do not object I will commit it now.

salu2

-- 
Thorsten Scherler<scherler.at.gmail.com>
codeBusters S.L. - web based systems
<consulting, training and solutions>

http://www.codebusters.es/


Mime
View raw message