You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Voyer Henry <He...@loto-quebec.com> on 2003/11/13 21:34:03 UTC

RE : betwixt Beginner

Hi.

I had the same problem and it took me a while to understand how to make it
work

First download the latest cvs build. Toy a bit with it. Look the examples.
In resume it works like this.

To marshall

	StringWriter outputWriter = new StringWriter();
	BeanWriter writer = new BeanWriter(outputWriter);

      writer.getBindingConfiguration().setMapIDs(false);

	writer.setWriteEmptyElements(true);
	writer.getXMLIntrospector().setAttributesForPrimitives(false);
	writer.enablePrettyPrint();
	// set a custom name mapper for attributes
	writer.getXMLIntrospector().setAttributeNameMapper(new
HyphenatedNameMapper());
	// set a custom name mapper for elements
	writer.getXMLIntrospector().setElementNameMapper(new
DecapitalizeNameMapper());

	writer.write("myobjectname", MyObject);

	String thexml = outputWriter.toString();

Unmarshall

		StringReader xmlReader = new StringReader(thexml);

		BeanReader beanReader = new BeanReader();

	
beanReader.getXMLIntrospector().setWrapCollectionsInElement(true);

		beanReader.setBindingConfiguration(configuration);

		String name = nameStrategy(classType.getName());
		beanReader.registerBeanClass("myObjectName",
MyObject.class);

		MyObject object = (MyObject) beanReader.parse(xmlReader);

Hope this help

regards


-----Message d'origine-----
De : Sunitha Muthireddy [mailto:smuthireddy@arccorp.com] 
Envoyé : 13 novembre, 2003 13:34
À : 'commons-user@jakarta.apache.org'
Objet : betwixt Beginner


I am trying to use betwixt but I do not see any good documentation or
examples to use CreateRule. 

And also the documentation doesn't match src file. Did I do something wrong?

Ex : There is no class calledBindingConfiguration in src files. And
BasicReader doesn't have setBindingConfiguration property. 

Thank you 

-Sunitha



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org