@Override public DOMImplementation getDOMImplementation() { return delegate.getDOMImplementation(); }
public Document newDocument(String uri, String qname) throws ParserConfigurationException { if (_domImplementation == null) { _domImplementation = DocumentBuilderFactory.newInstance() .newDocumentBuilder().getDOMImplementation(); } return _domImplementation.createDocument(uri, qname, null); } }
private static Document getDummyDocument( ) { try { if ( dbf == null ) { dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware( true ); dbf.setValidating( false ); } db = dbf.newDocumentBuilder(); DOMImplementation dim = db.getDOMImplementation(); d = dim.createDocument("http://java.sun.com/jaxp/xpath", "dummyroot", null); return d; } catch ( Exception e ) { e.printStackTrace(); } return null; }
private static Document getDummyDocument( ) { // we don't need synchronization here; even if two threads // enter this code at the same time, we just waste a little time if(d==null) { DOMImplementation dim = getParser().getDOMImplementation(); d = dim.createDocument("http://java.sun.com/jaxp/xpath", "dummyroot", null); } return d; }
private static Document getDummyDocument( ) { // we don't need synchronization here; even if two threads // enter this code at the same time, we just waste a little time if(d==null) { DOMImplementation dim = getParser().getDOMImplementation(); d = dim.createDocument("http://java.sun.com/jaxp/xpath", "dummyroot", null); } return d; }
private static Document getDummyDocument( ) { try { if ( dbf == null ) { dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware( true ); dbf.setValidating( false ); } db = dbf.newDocumentBuilder(); DOMImplementation dim = db.getDOMImplementation(); d = dim.createDocument("http://java.sun.com/jaxp/xpath", "dummyroot", null); return d; } catch ( Exception e ) { e.printStackTrace(); } return null; }
public static Document newDocument() { Document doc = docBuilder.getDOMImplementation().createDocument(getNamespace(), getRootTagname(), null); Element root = doc.getDocumentElement(); root.setAttribute("version", getVersion()); root.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); return doc; }
public static Document newDocument() { Document doc = docBuilder.getDOMImplementation().createDocument(getNamespace(), getRootTagname(), null); Element root = doc.getDocumentElement(); root.setAttribute("version", getVersion()); root.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); return doc; }
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); DOMImplementation impl = builder.getDOMImplementation(); Document xmldoc = impl.createDocument("http://www.w3.org/2001/XMLSchema", "xs:schema", null); xmldoc.getDocumentElement().setAttribute("targetNamespace", "urn:org:jgroups");
doc = builder.getDOMImplementation().createDocument( orig.getDocumentElement().getNamespaceURI(), orig.getDocumentElement().getTagName(), builder.getDOMImplementation().createDocumentType( orig.getDoctype().getName(), orig.getDoctype().getPublicId(),
/** * Obtains DOMImpementaton interface providing a number of methods for performing * operations that are independent of any particular DOM instance. * * @throw DOMException <code>NOT_SUPPORTED_ERR</code> if cannot get DOMImplementation * @throw FactoryConfigurationError Application developers should never need to directly catch errors of this type. * * @return DOMImplementation implementation */ private static DOMImplementation getDOMImplementation() throws DOMException { //can be made public DocumentBuilderFactory factory = getFactory(false, false); try { return factory.newDocumentBuilder().getDOMImplementation(); } catch (ParserConfigurationException ex) { throw new DOMException( DOMException.NOT_SUPPORTED_ERR, "Cannot create parser satisfying configuration parameters" ); //NOI18N } catch (RuntimeException e) { // E.g. #36578, IllegalArgumentException. Try to recover gracefully. throw (DOMException) new DOMException(DOMException.NOT_SUPPORTED_ERR, e.toString()).initCause(e); } }
public boolean init( StepMetaInterface smi, StepDataInterface sdi ) { meta = (AddXMLMeta) smi; data = (AddXMLData) sdi; if ( !super.init( smi, sdi ) ) { return false; } try { setSerializer( TransformerFactory.newInstance().newTransformer() ); setDomImplentation( XMLParserFactoryProducer.createSecureDocBuilderFactory().newDocumentBuilder().getDOMImplementation() ); if ( meta.getEncoding() != null ) { getSerializer().setOutputProperty( OutputKeys.ENCODING, meta.getEncoding() ); } if ( meta.isOmitXMLheader() ) { getSerializer().setOutputProperty( OutputKeys.OMIT_XML_DECLARATION, "yes" ); } } catch ( TransformerConfigurationException e ) { return false; } catch ( ParserConfigurationException e ) { return false; } return true; }
DOMImplementation domImpl = db.getDOMImplementation(); Document document = buildExampleDocumentWithNamespaces(domImpl); serialize(domImpl, document);
protected void printResponse() { try { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); DOMImplementationLS ls = (DOMImplementationLS)docBuilder.getDOMImplementation(); LSSerializer lss = ls.createLSSerializer(); System.out.println(lss.writeToString(_docResponse)); } catch (ParserConfigurationException e) { s_logger.error("Error parsing the repsonse : " + e.toString()); } } }
public static String getHello() { try { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); DOMImplementation domImpl = docBuilder.getDOMImplementation(); // Root elements. Document doc = domImpl.createDocument(s_namespace, "nc:hello", null); // Client capacity. We are only supporting basic capacity. Element capabilities = doc.createElement("nc:capabilities"); Element capability = doc.createElement("nc:capability"); capability.setTextContent("urn:ietf:params:xml:ns:netconf:base:1.0"); capabilities.appendChild(capability); doc.getDocumentElement().appendChild(capabilities); return serialize(domImpl, doc); } catch (ParserConfigurationException e) { s_logger.error("Error while creating hello message : " + e.getMessage()); return null; } catch (DOMException e) { s_logger.error("Error while creating hello message : " + e.getMessage()); return null; } }
public static String getAddPortProfile(String name, PortProfileType type, BindingType binding, SwitchPortMode mode, int vlanid, String vdc, String espName) { try { // Create the document and root element. DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); DOMImplementation domImpl = docBuilder.getDOMImplementation(); Document doc = createDocument(domImpl); // Edit configuration command. Element editConfig = doc.createElement("nf:edit-config"); doc.getDocumentElement().appendChild(editConfig); // Command to get into exec configure mode. Element target = doc.createElement("nf:target"); Element running = doc.createElement("nf:running"); target.appendChild(running); editConfig.appendChild(target); // Command to create the port profile with the desired configuration. Element config = doc.createElement("nf:config"); config.appendChild(configPortProfileDetails(doc, name, type, binding, mode, vlanid, vdc, espName)); editConfig.appendChild(config); return serialize(domImpl, doc); } catch (ParserConfigurationException e) { s_logger.error("Error while creating add port profile message : " + e.getMessage()); return null; } catch (DOMException e) { s_logger.error("Error while creating add port profile message : " + e.getMessage()); return null; } }
public static String getDeletePortProfile(String portName) { try { // Create the document and root element. DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); DOMImplementation domImpl = docBuilder.getDOMImplementation(); Document doc = createDocument(domImpl); // Edit configuration command. Element editConfig = doc.createElement("nf:edit-config"); doc.getDocumentElement().appendChild(editConfig); // Command to get into exec configure mode. Element target = doc.createElement("nf:target"); Element running = doc.createElement("nf:running"); target.appendChild(running); editConfig.appendChild(target); // Command to create the port profile with the desired configuration. Element config = doc.createElement("nf:config"); config.appendChild(deletePortProfileDetails(doc, portName)); editConfig.appendChild(config); return serialize(domImpl, doc); } catch (ParserConfigurationException e) { s_logger.error("Error while creating delete port profile message : " + e.getMessage()); return null; } catch (DOMException e) { s_logger.error("Error while creating delete port profile message : " + e.getMessage()); return null; } }
public static String getServicePolicy(String policyMap, String portProfile, boolean attach) { try { // Create the document and root element. DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); DOMImplementation domImpl = docBuilder.getDOMImplementation(); Document doc = createDocument(domImpl); // Edit configuration command. Element editConfig = doc.createElement("nf:edit-config"); doc.getDocumentElement().appendChild(editConfig); // Command to get into exec configure mode. Element target = doc.createElement("nf:target"); Element running = doc.createElement("nf:running"); target.appendChild(running); editConfig.appendChild(target); // Command to create the port profile with the desired configuration. Element config = doc.createElement("nf:config"); config.appendChild(serviceDetails(doc, policyMap, portProfile, attach)); editConfig.appendChild(config); return serialize(domImpl, doc); } catch (ParserConfigurationException e) { s_logger.error("Error while creating attach/detach service policy message : " + e.getMessage()); return null; } catch (DOMException e) { s_logger.error("Error while creating attach/detach service policy message : " + e.getMessage()); return null; } }
public static String getUpdatePortProfile(String name, SwitchPortMode mode, List<Pair<VsmCommand.OperationType, String>> params) { try { // Create the document and root element. DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); DOMImplementation domImpl = docBuilder.getDOMImplementation(); Document doc = createDocument(domImpl); // Edit configuration command. Element editConfig = doc.createElement("nf:edit-config"); doc.getDocumentElement().appendChild(editConfig); // Command to get into exec configure mode. Element target = doc.createElement("nf:target"); Element running = doc.createElement("nf:running"); target.appendChild(running); editConfig.appendChild(target); // Command to update the port profile with the desired configuration. Element config = doc.createElement("nf:config"); config.appendChild(configPortProfileDetails(doc, name, mode, params)); editConfig.appendChild(config); return serialize(domImpl, doc); } catch (ParserConfigurationException e) { s_logger.error("Error while creating update port profile message : " + e.getMessage()); return null; } catch (DOMException e) { s_logger.error("Error while creating update port profile message : " + e.getMessage()); return null; } }
public static String getVServiceNode(String vlanId, String ipAddr) { try { // Create the document and root element. DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); DOMImplementation domImpl = docBuilder.getDOMImplementation(); Document doc = createDocument(domImpl); // Edit configuration command. Element editConfig = doc.createElement("nf:edit-config"); doc.getDocumentElement().appendChild(editConfig); // Command to get into exec configure mode. Element target = doc.createElement("nf:target"); Element running = doc.createElement("nf:running"); target.appendChild(running); editConfig.appendChild(target); // Command to create the port profile with the desired configuration. Element config = doc.createElement("nf:config"); config.appendChild(configVServiceNodeDetails(doc, vlanId, ipAddr)); editConfig.appendChild(config); return serialize(domImpl, doc); } catch (ParserConfigurationException e) { s_logger.error("Error while adding vservice node for vlan " + vlanId + ", " + e.getMessage()); return null; } catch (DOMException e) { s_logger.error("Error while adding vservice node for vlan " + vlanId + ", " + e.getMessage()); return null; } }