List<Map<String,String>> saxFilterProperties = new ArrayList<Map<String,String>>();
// setup saxfilters
if (this.saxFilterConfigs.size() > 0) {
Iterator<SAXFilterConfig> j = saxFilterConfigs.iterator();
SAXFilterConfig sc = j.next();
SAXFilter first = this.manager.getSAXFilter(sc.getFilterName());
saxFilterProperties.add(new MergeMap<String,String>(first.getProperties(), context));
first.setContentHandler(this.serializer);
handler = first;
first.setProperties(sc.getProperties());
while (j.hasNext()) {
sc = j.next();
SAXFilter f = this.manager.getSAXFilter(sc.getFilterName());
f.setContentHandler(first);
saxFilterProperties.add(f.getProperties());
f.setProperties(sc.getProperties());
first = f;
}
} else {
// no filter
handler = this.serializer;
}
Map<String,String> oldProbs = this.serializer.getProperties();
this.serializer.setProperties(new MergeMap<String,String>(this.serializerProperties,context));
// invoke the filter and serializer
this.serializer.setOutput(out);
try {
Map<String,String> oldGenProps = this.generator.getProperties();
this.generator.setProperties(this.generatorProperties);
this.generator.generate(doc, handler, context);
// restore the old props
this.generator.setProperties(oldGenProps);
} catch (SAXException e) {
throw new ProcessorException(e);
}
// restore the serializer properties
this.serializer.setProperties(oldProbs);
// restore the filter properties
for (int x = 0; x < saxFilterProperties.size(); x++) {
SAXFilterConfig sc = (SAXFilterConfig) saxFilterConfigs.get(x);
this.manager.getSAXFilter(sc.getFilterName()).setProperties(saxFilterProperties.get(x));
}
}