commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Ross" <>
Subject [Betwixt] reading/writing xml with existing @id attribute
Date Wed, 08 Jan 2003 00:05:38 GMT
First, I'm new to Betwixt, but by no means new to the Digester.  I've
used the Digester successfully for several projects.
I'm having a problem.  I cannot figure out how to have my existing xml
be read/written properly (without a betwixt file), when my XML root
element already contains an attribute @id and also has (what Betwixt
classifies as a 'primitive') an element <name>, which is a String.  For
<customer id="111">
       <name>XYZ LLC</name>
BeanReader reader = new BeanReader();               
XMLIntrospector x =  new XMLIntrospector();
            x.setElementNameMapper(new DecapitalizeNameMapper());
reader.registerBeanClass( Customer.class );        
The problem lies in the x.setAttributesForPrimitives(true);.  This works
for @id, but not for <name>, or vice versa when set to false when is:
public class Customer{
            private String id;
            private String name;
I know I can do the following and make it work, but this is somewhat
bothersome since I have to do this for every entity with an id:
<?xml version="1.0" encoding="UTF-8"?>
<info primitiveTypes="element">
       <element name="customer">
             <attribute name="id" property="id"/>
How can I get both @id and <name> to be read/written properly
programmatically, exactly as the source file shows?   It would be easier
for me to specify an AttributeDescriptor generically, instead of
providing a betwixt file for all of them.
Am I missing something here?
Kevin Ross

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