1 2 | // Obtain an instance of an XMLReader implementation from a system property XMLReader parser = org.xml.sax.helpers.XMLReaderFactory.createXMLReader(); |
1 | java -Dorg.xml.sax.driver=org.apache.xerces.parsers.SAXParser some.sample.Class |
1 2 3 4 5 6 7 8 9 10 11 12 13 | // Obtain an instance of an XMLReader implementation from a system property XMLReader parser = org.xml.sax.helpers.XMLReaderFactory.createXMLReader(); String featureName = "some feature URI"; boolean featureOn = true; try { parser.setFeature(featureName, featureOn); } catch (SAXNotRecognizedException e) { System.err.println("Unknown feature specified: " + e.getMessage()); } catch (SAXNotSupportedException e) { System.err.println("Unsupported feature specified: " + e.getMessage()); } catch (SAXException e) { System.err.println("Error in setting feature: " + e.getMessage()); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | // Obtain an instance of an XMLReader implementation from a system property XMLReader parser = org.xml.sax.helpers.XMLReaderFactory.createXMLReader(); try { // Turn on validation parser.setFeature("http://xml.org/sax/features/validation", true); // Ensure namespace processing is on (the default) parser.setFeature("http://xml.org/sax/features/namespaces", true); } catch (SAXNotRecognizedException e) { System.err.println("Unknown feature specified: " + e.getMessage()); } catch (SAXNotSupportedException e) { System.err.println("Unsupported feature specified: " + e.getMessage()); } catch (SAXException e) { System.err.println("Error in setting feature: " + e.getMessage()); } |
1 2 3 4 5 6 7 8 9 10 11 12 | // Obtain an instance of an XMLReader implementation from a system property XMLReader parser = org.xml.sax.helpers.XMLReaderFactory.createXMLReader(); String propertyName = "some property URI"; try { parser.setProperty(propertyName, obj-arg); } catch (SAXNotRecognizedException e) { System.err.println("Unknown property specified: " + e.getMessage()); } catch (SAXNotSupportedException e) { System.err.println("Unsupported property specified: " + e.getMessage()); } catch (SAXException e) { System.err.println("Error in setting property: " + e.getMessage()); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | // Obtain an instance of an XMLReader implementation from a system property XMLReader parser = org.xml.sax.helpers.XMLReaderFactory.createXMLReader(); try { // Set the chunk to read in by SAX parser.setProperty("http://apache.org/xml/properties/input-buffer-size", new Integer(2048)); // Set a LexicalHandler parser.setProperty("http://xml.org/sax/properties/lexical-handler", new MyLexicalHandler()); } catch (SAXNotRecognizedException e) { System.err.println("Unknown feature specified: " + e.getMessage()); } catch (SAXNotSupportedException e) { System.err.println("Unsupported feature specified: " + e.getMessage()); } catch (SAXException e) { System.err.println("Error in setting feature: " + e.getMessage()); } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |