Hi Chris, Yes, a nice solution to a somewhat unusual problem. Of course, it's also possible to just define a separate binding that doesn't include the values you want to suppress on output - but if you're suppressing different combinations of attributes at different times this would require a different binding for each combination.
- Dennis Dennis M. Sosnoski SOA and Web Services in Java Training and Consulting http://www.sosnoski.com - http://www.sosnoski.co.nz Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117 netb0y wrote: > Just to share what I have learned, extending the > GenericXMLWriter class allows you to filter the output > xml... > > import java.util.Set; > import java.io.IOException; > import org.jibx.runtime.impl.GenericXMLWriter; > > public class JibxXMLWriter extends GenericXMLWriter { > > private HashSet attributes; > > public JibxXMLWriter(java.lang.String[] uris, Set > attributes) { > super(uris); > this.attributes = attributes; > } > > public void addAttribute(int index, String name, > String value) throws IOException { > if (attributes.contains(name)) { > super.addAttribute(index, name, value); > } > } > } > > Then when marshalling... > > IBindingFactory bFact = getBindingFactory(); > JibxXMLWriter jibxXMLWriter = new > JibxXMLWriter(bFact.getNamespaces(), > desiredAttribSet); > jibxXMLWriter.setOutput(new BufferedWriter(new > OutputStreamWriter(os)), UTF8Escaper.getInstance()); > marshaller.setXmlWriter(jibxXMLWriter); > marshaller.marshalDocument(obj); > marshaller.endDocument(); > > > -Chris > > > --- netb0y <[EMAIL PROTECTED]> wrote: > > >> Is there a way to filter the output xml when >> marshalling? I have mapped all fields in my object >> but there are instances where I do not want to write >> some fields to xml when marshalling. I can do this >> by setting the value to null but I was hoping there >> is another method of doing this. >> >> Thanks, >> Chris >> >> >> >> >> > ____________________________________________________________________________________ > >> Don't pick lemons. >> See all the new 2007 cars at Yahoo! Autos. >> http://autos.yahoo.com/new_cars.html >> >> >> > ------------------------------------------------------------------------- > >> Take Surveys. Earn Cash. Influence the Future of IT >> Join SourceForge.net's Techsay panel and you'll get >> the chance to share your >> opinions on IT & business topics through brief >> surveys-and earn cash >> >> > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > >> _______________________________________________ >> jibx-users mailing list >> jibx-users@lists.sourceforge.net >> >> > https://lists.sourceforge.net/lists/listinfo/jibx-users > > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > jibx-users mailing list > jibx-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jibx-users > > ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ jibx-users mailing list jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users