Here are the examples of the java api class com.sun.org.apache.xerces.internal.parsers.DOMParser taken from open source projects.
1. SchemaGrammar#getDOMParser()
Project: openjdk
File: SchemaGrammar.java
File: SchemaGrammar.java
// annotation support synchronized DOMParser getDOMParser() { if (fDOMParser != null) { DOMParser parser = (DOMParser) fDOMParser.get(); if (parser != null) { return parser; } } // REVISIT: when schema handles XML 1.1, will need to // revisit this (and the practice of not prepending an XML decl to the annotation string XML11Configuration config = new XML11Configuration(fSymbolTable); // note that this should never produce errors or require // entity resolution, so just a barebones configuration with // a couple of feature set will do fine config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE, true); config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE, false); DOMParser parser = new DOMParser(config); try { parser.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.DEFER_NODE_EXPANSION_FEATURE, false); } catch (SAXException exc) { } fDOMParser = new SoftReference(parser); return parser; }
2. XSAnnotationImpl#writeToDOM()
Project: openjdk
File: XSAnnotationImpl.java
File: XSAnnotationImpl.java
// this creates the new Annotation element as the first child // of the Node private synchronized void writeToDOM(Node target, short type) { Document futureOwner = (type == XSAnnotation.W3C_DOM_ELEMENT) ? target.getOwnerDocument() : (Document) target; DOMParser parser = fGrammar.getDOMParser(); StringReader aReader = new StringReader(fData); InputSource aSource = new InputSource(aReader); try { parser.parse(aSource); } catch (SAXException e) { } catch (IOException i) { } Document aDocument = parser.getDocument(); parser.dropDocumentReferences(); Element annotation = aDocument.getDocumentElement(); Node newElem = null; if (futureOwner instanceof CoreDocumentImpl) { newElem = futureOwner.adoptNode(annotation); // adoptNode will return null when the DOM implementations are not compatible. if (newElem == null) { newElem = futureOwner.importNode(annotation, true); } } else { newElem = futureOwner.importNode(annotation, true); } target.insertBefore(newElem, target.getFirstChild()); }
3. DocumentBuilderFactoryImpl#getAttribute()
Project: openjdk
File: DocumentBuilderFactoryImpl.java
File: DocumentBuilderFactoryImpl.java
/** * Allows the user to retrieve specific attributes on the underlying * implementation. */ public Object getAttribute(String name) throws IllegalArgumentException { // See if it's in the attributes Map if (attributes != null) { Object val = attributes.get(name); if (val != null) { return val; } } DOMParser domParser = null; try { // We create a dummy DocumentBuilderImpl in case the attribute // name is not one that is in the attributes map. domParser = new DocumentBuilderImpl(this, attributes, features).getDOMParser(); return domParser.getProperty(name); } catch (SAXException se1) { try { boolean result = domParser.getFeature(name); return result ? Boolean.TRUE : Boolean.FALSE; } catch (SAXException se2) { throw new IllegalArgumentException(se1.getMessage()); } } }