use of org.w3c.dom.DOMImplementation in project robovm by robovm.
the class DOMImplementationCreateDocument method testCreateDocument4.
public void testCreateDocument4() throws Throwable {
Document doc;
DOMImplementation domImpl;
String namespaceURI = null;
String qualifiedName = "dom:root";
DocumentType docType = null;
doc = (Document) load("staffNS", builder);
domImpl = doc.getImplementation();
{
boolean success = false;
try {
domImpl.createDocument(namespaceURI, qualifiedName, docType);
} catch (DOMException ex) {
success = (ex.code == DOMException.NAMESPACE_ERR);
}
assertTrue("domimplementationcreatedocument04", success);
}
}
use of org.w3c.dom.DOMImplementation in project robovm by robovm.
the class DocumentTypePublicId method testGetPublicId.
/**
* Runs the test case.
* @throws Throwable Any uncaught exception causes test to fail
*/
public void testGetPublicId() throws Throwable {
Document doc;
DocumentType docType;
DOMImplementation domImpl;
String publicId;
String nullNS = null;
doc = (Document) load("staffNS", builder);
domImpl = doc.getImplementation();
docType = domImpl.createDocumentType("l2:root", "PUB", nullNS);
publicId = docType.getPublicId();
assertEquals("documenttypepublicid01", "PUB", publicId);
}
use of org.w3c.dom.DOMImplementation in project robovm by robovm.
the class DocumentTypeSystemId method testGetSystemId.
/**
* Runs the test case.
* @throws Throwable Any uncaught exception causes test to fail
*/
public void testGetSystemId() throws Throwable {
Document doc;
DocumentType docType;
DOMImplementation domImpl;
String publicId;
String systemId;
doc = (Document) load("staffNS", builder);
domImpl = doc.getImplementation();
docType = domImpl.createDocumentType("l2:root", "PUB", "SYS");
publicId = docType.getPublicId();
systemId = docType.getSystemId();
assertEquals("documenttypepublicid01", "PUB", publicId);
assertEquals("documenttypesystemid01", "SYS", systemId);
}
use of org.w3c.dom.DOMImplementation in project ddf by codice.
the class AbstractStsRealm method getFormattedXml.
/**
* Transform into formatted XML.
*/
private String getFormattedXml(Node node) {
Document document = node.getOwnerDocument().getImplementation().createDocument("", "fake", null);
Element copy = (Element) document.importNode(node, true);
document.importNode(node, false);
document.removeChild(document.getDocumentElement());
document.appendChild(copy);
DOMImplementation domImpl = document.getImplementation();
DOMImplementationLS domImplLs = (DOMImplementationLS) domImpl.getFeature("LS", "3.0");
if (null != domImplLs) {
LSSerializer serializer = domImplLs.createLSSerializer();
serializer.getDomConfig().setParameter("format-pretty-print", true);
return serializer.writeToString(document);
} else {
return "";
}
}
use of org.w3c.dom.DOMImplementation in project JGroups by belaban.
the class XMLSchemaGenerator method main.
public static void main(String[] args) {
String outputDir = "./";
for (int i = 0; i < args.length; i++) {
String arg = args[i];
if ("-o".equals(arg)) {
outputDir = args[++i];
} else {
System.out.println("XMLSchemaGenerator -o <path to newly created xsd schema file>");
return;
}
}
String version = Version.major + "." + Version.minor;
File f = new File(outputDir, "jgroups-" + version + ".xsd");
try {
FileWriter fw = new FileWriter(f, false);
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");
xmldoc.getDocumentElement().setAttribute("elementFormDefault", "qualified");
xmldoc.getDocumentElement().setAttribute("attributeFormDefault", "qualified");
xmldoc.getDocumentElement().setAttribute("version", version);
Element complexType = xmldoc.createElement("xs:complexType");
complexType.setAttribute("name", "ConfigType");
xmldoc.getDocumentElement().appendChild(complexType);
Element allType = xmldoc.createElement("xs:choice");
allType.setAttribute("maxOccurs", "unbounded");
complexType.appendChild(allType);
generateProtocolSchema(xmldoc, allType, PACKAGES);
Element xsElement = xmldoc.createElement("xs:element");
xsElement.setAttribute("name", "config");
xsElement.setAttribute("type", "ConfigType");
xmldoc.getDocumentElement().appendChild(xsElement);
DOMSource domSource = new DOMSource(xmldoc);
StreamResult streamResult = new StreamResult(fw);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.METHOD, "xml");
serializer.setOutputProperty(OutputKeys.INDENT, "yes");
serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
serializer.transform(domSource, streamResult);
fw.flush();
fw.close();
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations