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
> [EMAIL PROTECTED]
>
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
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to