H
Henri Sivonen
I am generating XML by emitting SAX events programmatically from Java.
However, there's a lot of boilerplate markup, so being able to generate
code from XML would be nice.
Is there a tool that would take an XML file like this
<?args org.xml.sax.ContentHandler ch, com.example.Foo foo ?>
<baz xmlns="http://example.com/fooml/">
<?code foo.bar(ch); ?>
</baz>
and would generate a Java class like this
public class GeneratedEmitter {
public static void emit(org.xml.sax.ContentHandler ch,
com.example.Foo foo) throws SAXException {
ch.startDocument();
ch.startElement("http://example.com/fooml/", "baz", "baz", new
AttributesImpl());
foo.bar(ch);
ch.endElement("http://example.com/fooml/", "baz", "baz");
ch.endDocument();
}
}
?
However, there's a lot of boilerplate markup, so being able to generate
code from XML would be nice.
Is there a tool that would take an XML file like this
<?args org.xml.sax.ContentHandler ch, com.example.Foo foo ?>
<baz xmlns="http://example.com/fooml/">
<?code foo.bar(ch); ?>
</baz>
and would generate a Java class like this
public class GeneratedEmitter {
public static void emit(org.xml.sax.ContentHandler ch,
com.example.Foo foo) throws SAXException {
ch.startDocument();
ch.startElement("http://example.com/fooml/", "baz", "baz", new
AttributesImpl());
foo.bar(ch);
ch.endElement("http://example.com/fooml/", "baz", "baz");
ch.endDocument();
}
}
?