Hmm.. hold back on the patch ;)).. Found another issue.. It is also using the attributenamemapper for subelemenents.. Fixing that now..
Mvgr, Martin On Wed, 2002-06-05 at 17:18, Martin van den Bemt wrote: > Hi James, > > Finally found the problem. The nameMapper is also used for attributes.. > so if I have an xml file like > <PHYSICAL_SCHEMA autocreate="yes"/> > > You end up with trouble ;).. Since autocreate will be mapped to the > attribute AUTOCREATE, which doesn't exist. > > So I added an extra nameMapper setter (setAttributeNameMapper), which > you can call if you want to use a different nameMapper for attributes. > > I have chosen not to make a specific attributenamemapper Interface / > abstract class for simplicity and easier reuse of code.. > > The default is to use the normal NameMapper, so no backward > compatibility issues on this. > > If you don't mind, I will make my testcases a little bit later. > (hopefully tonight, or else on sunday, since I am off sailing for a > couple of days..) > Hope you wil apply the patch however, ran all tests and it doesn't break > backward compatibility. > > Hope it is usefull for you too ;) > > Mvgr, > Martin > > > > > ---- > > Index: XMLIntrospector.java > =================================================================== > RCS file: >/home/cvspublic/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java,v > retrieving revision 1.28 > diff -u -r1.28 XMLIntrospector.java > --- XMLIntrospector.java 3 Jun 2002 20:51:08 -0000 1.28 > +++ XMLIntrospector.java 5 Jun 2002 15:03:48 -0000 > @@ -93,6 +93,7 @@ > * Later requests for the same class will return the cached value.</p> > * > * @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a> > + * @author <a href-"mailto:[EMAIL PROTECTED]">Martin van den Bemt</a> > * @version $Id: XMLIntrospector.java,v 1.28 2002/06/03 20:51:08 jon Exp $ > */ > public class XMLIntrospector { > @@ -123,6 +124,12 @@ > /** The strategy used to convert bean type names into element names */ > private NameMapper nameMapper; > > + /** > + * The strategy used to convert bean type names into attribute names > + * It will default to the normal nameMapper. > + */ > + private NameMapper attributeNameMapper; > + > /** Base constructor */ > public XMLIntrospector() { > } > @@ -329,13 +336,32 @@ > } > return nameMapper; > } > + /** > + * @return the strategy used to convert bean type names into attribute > + * names. If no attributeNamemapper is known, it will default to the NameMapper > + */ > + public NameMapper getAttributeNameMapper() { > + if (attributeNameMapper == null) { > + attributeNameMapper = getNameMapper(); > + } > + return attributeNameMapper; > + } > > /** > * Sets the strategy used to convert bean type names into element names > + * @param nameMapper > */ > public void setNameMapper(NameMapper nameMapper) { > this.nameMapper = nameMapper; > } > + > + /** > + * Sets the strategy used to convert bean type names into attribute names > + * @param nameMapper > + */ > + public void setAttributeNameMapper(NameMapper nameMapper) { > + this.attributeNameMapper = nameMapper; > + } > > > > @@ -508,7 +534,7 @@ > elements.add( nodeDescriptor ); > } > > - nodeDescriptor.setLocalName( getNameMapper().mapTypeToElementName( >propertyDescriptor.getName() ) ); > + nodeDescriptor.setLocalName( getAttributeNameMapper().mapTypeToElementName( >propertyDescriptor.getName() ) ); > nodeDescriptor.setPropertyName( propertyDescriptor.getName() ); > nodeDescriptor.setPropertyType( type ); > > > ---- > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
