use of org.w3c.dom.DocumentType in project robovm by robovm.
the class InternalSubset method testGetInternalSubset.
/**
* Runs the test case.
* @throws Throwable Any uncaught exception causes test to fail
*/
public void testGetInternalSubset() throws Throwable {
Document doc;
DocumentType docType;
String internal;
doc = (Document) load("staff2", builder);
docType = doc.getDoctype();
internal = docType.getInternalSubset();
assertNull("internalSubsetNull", internal);
}
use of org.w3c.dom.DocumentType 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.DocumentType in project nokogiri by sparklemotion.
the class XmlDtd method setNode.
public void setNode(Ruby runtime, Node dtd) {
this.node = dtd;
notationClass = (RubyClass) runtime.getClassFromPath("Nokogiri::XML::Notation");
name = pubId = sysId = runtime.getNil();
if (dtd == null)
return;
// This is the dtd declaration stored in the document; it
// contains the DTD name (root element) and public and system
// ids. The actual declarations are in the NekoDTD 'dtd'
// variable. I don't know of a way to consolidate the two.
DocumentType otherDtd = dtd.getOwnerDocument().getDoctype();
if (otherDtd != null) {
name = stringOrNil(runtime, otherDtd.getNodeName());
pubId = nonEmptyStringOrNil(runtime, otherDtd.getPublicId());
sysId = nonEmptyStringOrNil(runtime, otherDtd.getSystemId());
}
}
use of org.w3c.dom.DocumentType in project generator by mybatis.
the class ConfigurationParser method parseConfiguration.
private Configuration parseConfiguration(InputSource inputSource) throws IOException, XMLParserException {
parseErrors.clear();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
try {
DocumentBuilder builder = factory.newDocumentBuilder();
builder.setEntityResolver(new ParserEntityResolver());
ParserErrorHandler handler = new ParserErrorHandler(warnings, parseErrors);
builder.setErrorHandler(handler);
Document document = null;
try {
document = builder.parse(inputSource);
} catch (SAXParseException e) {
throw new XMLParserException(parseErrors);
} catch (SAXException e) {
if (e.getException() == null) {
parseErrors.add(e.getMessage());
} else {
parseErrors.add(e.getException().getMessage());
}
}
if (parseErrors.size() > 0) {
throw new XMLParserException(parseErrors);
}
Configuration config;
Element rootNode = document.getDocumentElement();
DocumentType docType = document.getDoctype();
if (rootNode.getNodeType() == Node.ELEMENT_NODE && docType.getPublicId().equals(XmlConstants.IBATOR_CONFIG_PUBLIC_ID)) {
config = parseIbatorConfiguration(rootNode);
} else if (rootNode.getNodeType() == Node.ELEMENT_NODE && docType.getPublicId().equals(XmlConstants.MYBATIS_GENERATOR_CONFIG_PUBLIC_ID)) {
config = parseMyBatisGeneratorConfiguration(rootNode);
} else {
//$NON-NLS-1$
throw new XMLParserException(getString("RuntimeError.5"));
}
if (parseErrors.size() > 0) {
throw new XMLParserException(parseErrors);
}
return config;
} catch (ParserConfigurationException e) {
parseErrors.add(e.getMessage());
throw new XMLParserException(parseErrors);
}
}
use of org.w3c.dom.DocumentType in project OpenAM by OpenRock.
the class ServiceManager method validSMSDtdDocType.
/*
if (!validSMSDtdDocType(doc)) {
throw new SMSException(IUMSConstants.UMS_BUNDLE_NAME,
IUMSConstants.SMS_xml_invalid_doc_type, null);
}
// Before validating service schema, we need to check
// for AttributeSchema having the syntax of "password"
// and if present, encrypt the DefaultValues if any
checkAndEncryptPasswordSyntax(doc, true, decryptObj);
// Create service schema
NodeList nodes = doc.getElementsByTagName(SMSUtils.SERVICE);
for (int i = 0; (nodes != null) && (i < nodes.getLength()); i++) {
Node serviceNode = nodes.item(i);
String name = XMLUtils.getNodeAttributeValue(serviceNode,
SMSUtils.NAME);
String version = XMLUtils.getNodeAttributeValue(serviceNode,
SMSUtils.VERSION);
// Obtain the SMSSchema for Schema and PluginSchema
SMSSchema smsSchema = new SMSSchema(name, version, doc);
smsSchemas.put(name, smsSchema);
}
// Check if the schema element exists
/*if (XMLUtils.getChildNode(serviceNode, SMSUtils.SCHEMA) != null) {
validateServiceSchema(serviceNode);
ServiceSchemaManager.createService(token, smsSchema);
// Update the service name and version cached SMSEntry
if (serviceNames == null) {
serviceNames = CachedSubEntries.getInstance(token,
serviceDN);
}
serviceNames.add(name);
CachedSubEntries sVersions = (CachedSubEntries) serviceVersions
.get(name);
if (sVersions == null) {
// Not present, hence create it and add it
sVersions = CachedSubEntries.getInstance(token,
getServiceNameDN(name));
serviceVersions.put(name, sVersions);
}
sVersions.add(version);
sNames.add(name);
}
// Check if PluginSchema nodes exists
for (Iterator pluginNodes = XMLUtils.getChildNodes(serviceNode,
SMSUtils.PLUGIN_SCHEMA).iterator(); pluginNodes.hasNext();)
{
Node pluginNode = (Node) pluginNodes.next();
PluginSchema.createPluginSchema(token, pluginNode, smsSchema);
}
if (XMLUtils.getChildNode(serviceNode, SMSUtils.CONFIGURATION)
!= null) {
serviceNodes.add(serviceNode);
}
}
if (serviceNodes.size() > 0) {
clearCache();
}
/*
* Need to do this after all the schema has been loaded
*/
/*
for (Iterator i = serviceNodes.iterator(); i.hasNext(); ) {
Node svcNode = (Node)i.next();
String name = XMLUtils.getNodeAttributeValue(svcNode,
SMSUtils.NAME);
String version = XMLUtils.getNodeAttributeValue(svcNode,
SMSUtils.VERSION);
Node configNode = XMLUtils.getChildNode(svcNode,
SMSUtils.CONFIGURATION);
/*
* Store the configuration, will throw exception if
* the service configuration already exists
*/
/*
CreateServiceConfig.createService(this, name, version,
configNode, true, decryptObj);
}
return sNames;
return smsSchemas;
}*/
private boolean validSMSDtdDocType(Document doc) {
boolean valid = false;
DocumentType docType = doc.getDoctype();
if (docType != null) {
String dtdPath = docType.getSystemId();
if (dtdPath != null) {
int idx = dtdPath.lastIndexOf('/');
if (idx != -1) {
dtdPath = dtdPath.substring(idx + 1);
}
valid = dtdPath.equals("sms.dtd");
}
}
return valid;
}
Aggregations