View RSS Feed

Recent Blogs Posts

  1. Java SAX Schema Validation

    by , 04-27-2012 at 05:16 PM
    It is possible to turn on XML Schema validation during parsing with a SAXParser. Here is how it looks:
    Java Code:
    Schema schema = null;
    try {
      String language = XMLConstants.W3C_XML_SCHEMA_NS_URI;
      SchemaFactory factory = SchemaFactory.newInstance(language);
      schema = factory.newSchema(new File(name));
    } catch (Exception e) {
        e.printStackStrace();
    }
    
    
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setSchema(schema);
    ...
    Tags: sax schema Add / Edit Tags
    Categories
    SAX.