commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc DEXET <Marc.De...@dsi.cnrs.fr>
Subject RE : RE : [betwixt - dom4j] How to get a dom4j XML element from B eanWr iter
Date Fri, 28 Jan 2005 17:07:08 GMT
Now I get a new problem :

If I set : 
beanWriter.getXMLIntrospector().setAttributesForPrimitives(true);

I haven't element ( i.e. is null !) 

I quote back the source :
-----------------------------

    public static void main(String[] strings) throws IOException,
SAXException, IntrospectionException {
        SAXContentHandler h = new SAXContentHandler(new
DOMDocumentFactory());
        SAXBeanWriter beanWriter = new SAXBeanWriter(h);
        beanWriter.getXMLIntrospector().setAttributesForPrimitives(true);
        beanWriter.write( new PersonBean("Paul",22));
        Element el = h.getDocument().getRootElement();
        
        System.out.println(el.asXML());
    }

What's wrong ?


Marc DEXET wrote:
> Thank for all folks, I get the answer !
> 
> You have to use org.dom4j.io.SAXContentHandler.SAXContentHandler(
> org.dom4j.dom.DOMDocumentFactory ) constructor;
> 
> Marc DEXET wrote:
>> Hello guys
>> I would to get a dom4j xmlElement from a BeanWriter.
>> A use SAXBeanWriter and dom4j SAXContenetHandler but I get a strange
>> result
>>> 
>> <person id="1">
>>   Paul<name/>
>>   22<age/>
>> </person>
>> 
>> instead of
>> 
>> <person>
>>   <name>Paul</name>
>>   <age>22</age>
>> </person>
>> 
>> Have somebody an idea ?

-- 
Marc DeXeT
BEST - DSI Meudon
01.45.07.51.56
marc.dexet@dsi.cnrs.fr


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message