cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marcel Rouwenhorst" <marcel.rouwenho...@mobillion.nl>
Subject RE: Problem writing generator
Date Tue, 03 Jan 2006 09:40:43 GMT
Thanks Geert for answering! 


I do use the startPrefixMapping and endPrefixMapping

This are the two source code examples I tried: 

1 ----------------------

handler.startPrefixMapping("i18n", I18nTransformer.I18N_NAMESPACE_URI);

AttributesImpl attr = new AttributesImpl();
attr.addCDATAAttribute(I18nTransformer.I18N_NAMESPACE_URI, "key",
"i18n:" + "key", "some_key");

handler.startElement(null, "exception", "exception", null);
handler.startElement(I18nTransformer.I18N_NAMESPACE_URI, "text",
"i18n:text", attr);
        
handler.endElement(I18nTransformer.I18N_NAMESPACE_URI, "text",
"i18n:text");
handler.endElement(null, "exception", "exception");

handler.endPrefixMapping("i18n");

This example creates the following xml:
<exception>
	<i18n:text i18n:key="some_key"/>
</exception>

2---------------------

If I change the following 2 lines 

handler.startPrefixMapping("xmlns", I18nTransformer.I18N_NAMESPACE_URI);

attr.addCDATAAttribute(I18nTransformer.I18N_NAMESPACE_URI, "i18n",
"xmlns:i18n", I18nTransformer.I18N_NAMESPACE_URI);

This example creates the following xml:
<exception>
	<i18n:text xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
xmlns:i18n="http://apache.org/cocoon/i18n/2.1"/>
</exception>

You can see that there are 2 i18n:text
xmlns:i18n="http://apache.org/cocoon/i18n/2.1" 
I get an error "XML Parsing Error: duplicate attribute"

Thank you,
Marcel


-----Oorspronkelijk bericht-----
Van: Geert Josten [mailto:Geert.Josten@daidalos.nl] 
Verzonden: dinsdag 3 januari 2006 10:08
Aan: users@cocoon.apache.org
Onderwerp: Re: Problem writing generator

Are you using startPrefixMapping and endPrefixMapping to register the
i18n namespace?

Kind regards,
Geert

Marcel Rouwenhorst wrote:

> Hi,
> 
>  
> 
> I have a problem writing a generator. I want to write a generator for 
> exception handling. It should work something like the exception
generator.
> 
> The generator should create an output that looks like this
(simplified):
> 
>  
> 
> <exception xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
> 
> <i18n:text i18n:key="some_key">test</i18n:text>
> 
> </exception>
> 
>  
> 
> I get everything right except I can't create 
> xmlns:i18n="http://apache.org/cocoon/i18n/2.1" in the exception tag or

> any other tag.
> 
>  
> 
> I use the org.xml.sax.ContentHandler to create the xml. In the same
way 
> as the exception generator does.
> 
>  
> 
> Help is appreciated
> 
>  
> 
> Marcel
> 
>  
> 

-- 
Drs. G.P.H. Josten
Consultant



Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665  JZ  Bleiswijk
Tel: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
www.daidalos.nl


De informatie - verzonden in of met dit emailbericht - is afkomstig van
Daidalos BV en is 
uitsluitend bestemd voor de geadresseerde. Indien u dit bericht
onbedoeld hebt ontvangen, verzoeken 
wij u het te verwijderen. Aan dit bericht kunnen geen rechten worden
ontleend.

---------------------------------------------------------------------
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


Mime
View raw message