Advanced Customization > Services and Infrastructure Customization > Import Export Framework > How to Write Exp/Imp Handlers > DTD Files > How to Write a Class Export Handler
  
How to Write a Class Export Handler
1. Create a Class that extends ClassExporterImporterTemplate
2. Implement exportAttributes(Object obj, Exporter exp) method, which retrieves the data from the object and adds it to the XML DOM Document. The following is an example of this method for the object of “MyClass”:
public void exportAttributes (Object object, Exporter exporter) throws WTException {
try {

MyClass ob = (MyClass)object;
// export the local id
IxbHndHelper.exportAttribute(
ExpImpForLocalIdAttr.class, ob, fileXML, exporter);
// export other attributes that are specific to
// MyObject; e.g. name, number
IxbHndHelper.exportAttribute(
ExpImpForMyObjectAttr.class, ob, fileXML, exporter);
// export version information
IxbHndHelper.exportAttribute(
ExpImpForVersionAttr.class, ob, fileXML, exporter);
// export content
IxbHndHelper.exportAttribute(
ExpImpForContentAttr.class, ob, fileXML, exporter);

}
catch (Exception e) {
LogHelper.devExc ( e,
"exportAttributes: could not export
object=<"+object+">");
}
}
3. Override getRootTag() method, which returns the desired root tag for the object type to be exported. The following is an example of this method for the object of “MyClass”:
protected String getRootTag() {
return "MyClass";
}
4. Add an entry in the handlers XML file (<Windchill>\registry\ixb\handlers\coreX10.dtd) that specifies the class being exported (com.mycompany.MyObject), the XML DTD for core Windchill objects (standardX20.dtd), and the handler for the class (wt.ixb.handlers.forclasses.ExpImpForMyObject). An example entry follows:
<classExporter>
<class>com.mycompany.MyObject</class>
<dtd>standardX20.dtd</dtd>
<targetTag>default</target>
<handler>wt.ixb.handlers.forclasses.ExpImpForMyObject</handler>
</classExporter>