Skip to content

Instantly share code, notes, and snippets.

View zlpatel's full-sized avatar

Zeel Patel zlpatel

View GitHub Profile
@zlpatel
zlpatel / SAX XML Schema processing
Created December 9, 2016 19:36 — forked from helderdarocha/SAX XML Schema processing
Example processing a simple XML schema in SAX and generating a tree
public class SAXReaderExample {
public static final String PATH = "/tmp/resources";
public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException {
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader reader = sp.getXMLReader();
reader.setContentHandler(new SchemaSaxHandler());
reader.parse(new InputSource(new FileInputStream(new File(PATH, "source.xsd"))));