use of org.w3c.dom.DOMImplementation in project robovm by robovm.
the class DocumentCreateElementNS method testCreateElementNS6.
public void testCreateElementNS6() throws Throwable {
Document doc;
Document newDoc;
DocumentType docType = null;
DOMImplementation domImpl;
String namespaceURI = "http://www.w3.org/xml/1998/namespace ";
String qualifiedName = "xml:root";
doc = (Document) load("staffNS", builder);
domImpl = doc.getImplementation();
newDoc = domImpl.createDocument("http://www.w3.org/DOM/Test", "dom:doc", docType);
{
boolean success = false;
try {
newDoc.createElementNS(namespaceURI, qualifiedName);
} catch (DOMException ex) {
success = (ex.code == DOMException.NAMESPACE_ERR);
}
assertTrue("documentcreateelementNS06", success);
}
}
use of org.w3c.dom.DOMImplementation in project CloudStack-archive by CloudStack-extras.
the class VsmCommand method getAddPortProfile.
public static String getAddPortProfile(String name, PortProfileType type, BindingType binding, SwitchPortMode mode, int vlanid) {
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));
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;
}
}
use of org.w3c.dom.DOMImplementation in project CloudStack-archive by CloudStack-extras.
the class VsmCommand method getServicePolicy.
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;
}
}
use of org.w3c.dom.DOMImplementation in project CloudStack-archive by CloudStack-extras.
the class VsmCommand method getAddPolicyMap.
public static String getAddPolicyMap(String name, int averageRate, int maxRate, int burstRate) {
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(policyMapDetails(doc, name, averageRate, maxRate, burstRate));
editConfig.appendChild(config);
return serialize(domImpl, doc);
} catch (ParserConfigurationException e) {
s_logger.error("Error while creating policy map message : " + e.getMessage());
return null;
} catch (DOMException e) {
s_logger.error("Error while creating policy map message : " + e.getMessage());
return null;
}
}
use of org.w3c.dom.DOMImplementation in project CloudStack-archive by CloudStack-extras.
the class VsmCommand method getHello.
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;
}
}
Aggregations