SAX parser factory method. @return the SAXParserFactory we will use, creating one if necessary. @throws ParserConfigurationException Error creating parser @throws SAXNotSupportedException Error creating parser @throws SAXNotRecognizedException Error creating parser
()
| 625 | * @throws SAXNotRecognizedException Error creating parser |
| 626 | */ |
| 627 | public SAXParserFactory getFactory() |
| 628 | throws SAXNotRecognizedException, SAXNotSupportedException, ParserConfigurationException { |
| 629 | |
| 630 | if (factory == null) { |
| 631 | factory = SAXParserFactory.newInstance(); |
| 632 | |
| 633 | factory.setNamespaceAware(namespaceAware); |
| 634 | // Preserve xmlns attributes |
| 635 | if (namespaceAware) { |
| 636 | factory.setFeature("http://xml.org/sax/features/namespace-prefixes", true); |
| 637 | } |
| 638 | |
| 639 | factory.setValidating(validating); |
| 640 | if (validating) { |
| 641 | // Enable DTD validation |
| 642 | factory.setFeature("http://xml.org/sax/features/validation", true); |
| 643 | // Enable schema validation |
| 644 | factory.setFeature("http://apache.org/xml/features/validation/schema", true); |
| 645 | } |
| 646 | } |
| 647 | return factory; |
| 648 | } |
| 649 | |
| 650 | |
| 651 | /** |
no test coverage detected