本文整理汇总了Java中org.w3c.dom.Element.getOwnerDocument方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getOwnerDocument方法的具体用法?Java Element.getOwnerDocument怎么用?Java Element.getOwnerDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.w3c.dom.Element
的用法示例。
在下文中一共展示了Element.getOwnerDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: putSubprojects
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* Update subprojects of the project.
* Project is left modified and you must save it explicitely.
* @param helper AntProjectHelper instance
* @param subprojects list of paths to subprojects
*/
public static void putSubprojects(AntProjectHelper helper, List<String> subprojects) {
//assert ProjectManager.mutex().isWriteAccess();
ArrayList list = new ArrayList();
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
Element subproject = XMLUtil.findElement(data, "subprojects", Util.NAMESPACE); // NOI18N
if (subproject != null) {
data.removeChild(subproject);
}
subproject = doc.createElementNS(Util.NAMESPACE, "subprojects"); // NOI18N
XMLUtil.appendChildElement(data, subproject, rootElementsOrder);
Iterator it = subprojects.iterator();
while (it.hasNext()) {
String proj = (String)it.next();
Element projEl = doc.createElementNS(Util.NAMESPACE, "project"); // NOI18N
projEl.appendChild(doc.createTextNode(proj));
subproject.appendChild(projEl);
}
Util.putPrimaryConfigurationData(helper, data);
}
示例2: saveProperties
import org.w3c.dom.Element; //导入方法依赖的package包/类
public static Element saveProperties(
final Properties properties,
final Element element) {
final Document document = element.getOwnerDocument();
for (Object key: properties.keySet()) {
final Element propertyElement = document.createElement("property");
propertyElement.setAttribute("name", key.toString());
propertyElement.setTextContent(properties.get(key).toString());
element.appendChild(propertyElement);
}
return element;
}
示例3: saveLocalizedString
import org.w3c.dom.Element; //导入方法依赖的package包/类
public static Element saveLocalizedString(
final Map<Locale, String> map,
final Element element) {
final Document document = element.getOwnerDocument();
final Element defaultElement = document.createElement("default");
defaultElement.setTextContent(StringUtils.convertToAscii(
map.get(new Locale(StringUtils.EMPTY_STRING))));
element.appendChild(defaultElement);
for (Locale locale: map.keySet()) {
if (!map.get(locale).equals(map.get(new Locale(StringUtils.EMPTY_STRING)))) {
final Element localizedElement = document.createElement("localized");
localizedElement.setAttribute("locale", locale.toString());
localizedElement.setTextContent(StringUtils.convertToAscii(
map.get(locale)));
element.appendChild(localizedElement);
}
}
return element;
}
示例4: replaceDependencies
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* Replaces all original dependencies with the given <code>newDeps</code>.
*
* Checks for dependency cycles, throws {@link CyclicDependencyException} if new dependencies
* introduce dependency cycle and leaves current dependencies untouched.
*/
public void replaceDependencies(final Set<ModuleDependency> newDeps) throws CyclicDependencyException {
Set<ModuleDependency> addedDeps = new HashSet<ModuleDependency>(newDeps);
try {
SortedSet<ModuleDependency> currentDeps = getDirectDependencies();
addedDeps.removeAll(currentDeps);
String warning = getDependencyCycleWarning(addedDeps);
if (warning != null) {
throw new CyclicDependencyException(warning);
}
} catch (IOException x) { // getDirectDependencies
LOG.log(Level.INFO, null, x); // and skip check
}
Element _confData = getConfData();
Document doc = _confData.getOwnerDocument();
Element moduleDependencies = findModuleDependencies(_confData);
_confData.removeChild(moduleDependencies);
moduleDependencies = createModuleElement(doc, ProjectXMLManager.MODULE_DEPENDENCIES);
XMLUtil.appendChildElement(_confData, moduleDependencies, ORDER);
SortedSet<ModuleDependency> sortedDeps = new TreeSet<ModuleDependency>(newDeps);
for (ModuleDependency md : sortedDeps) {
createModuleDependencyElement(moduleDependencies, md, null);
}
project.putPrimaryConfigurationData(_confData);
this.directDeps = sortedDeps;
}
示例5: putContextMenuAction
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* Update context menu actions. Project is left modified and
* you must save it explicitely. This method stores all IDE actions
* before the custom actions what means that user's customization by hand
* (e.g. order of items) is lost.
* @param helper AntProjectHelper instance
* @param mappings list of <TargetMapping> instances for which the context
* menu actions will be created
*/
public static void putContextMenuAction(AntProjectHelper helper, List<TargetMapping> mappings) {
//assert ProjectManager.mutex().isWriteAccess();
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
Element viewEl = XMLUtil.findElement(data, "view", FreeformProjectType.NS_GENERAL); // NOI18N
if (viewEl == null) {
viewEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "view"); // NOI18N
XMLUtil.appendChildElement(data, viewEl, rootElementsOrder);
}
Element contextMenuEl = XMLUtil.findElement(viewEl, "context-menu", FreeformProjectType.NS_GENERAL); // NOI18N
if (contextMenuEl == null) {
contextMenuEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "context-menu"); // NOI18N
XMLUtil.appendChildElement(viewEl, contextMenuEl, viewElementsOrder);
}
for (Element ideActionEl : XMLUtil.findSubElements(contextMenuEl)) {
if (!ideActionEl.getLocalName().equals("ide-action")) { // NOI18N
continue;
}
contextMenuEl.removeChild(ideActionEl);
}
for (TargetMapping tm : sortMappings(mappings)) {
if (tm.context != null) {
// ignore context sensitive actions
continue;
}
Element ideAction = doc.createElementNS(FreeformProjectType.NS_GENERAL, "ide-action"); //NOI18N
ideAction.setAttribute("name", tm.name); // NOI18N
XMLUtil.appendChildElement(contextMenuEl, ideAction, contextMenuElementsOrder);
}
Util.putPrimaryConfigurationData(helper, data);
}
示例6: exportProcess
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* This method will return append the description of this process to the given father element.
*/
public void exportProcess(Element fatherElement, Process process) {
Element rootElement = XMLTools.addTag(fatherElement, ELEMENT_PROCESS);
rootElement.setAttribute("version", RapidMiner.getLongVersion());
Document doc = rootElement.getOwnerDocument();
if (!process.getAnnotations().isEmpty()) {
rootElement.appendChild(exportAnnotations(process.getAnnotations(), doc));
}
rootElement.appendChild(exportOperator(process.getRootOperator(), false, doc));
}
示例7: generateEmptyModuleTemplate
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* Generates a basic <em>project.xml</em> templates into the given
* <code>projectXml</code> for <em>standalone</em> or <em>module in
* suite</em> module.
*/
static void generateEmptyModuleTemplate(FileObject projectXml, String cnb,
NbModuleType moduleType, String... compileDepsCnbs) throws IOException {
Document prjDoc = XMLUtil.createDocument("project", PROJECT_NS, null, null); // NOI18N
// generate general project elements
Element typeEl = prjDoc.createElementNS(PROJECT_NS, "type"); // NOI18N
typeEl.appendChild(prjDoc.createTextNode(NbModuleProject.TYPE));
prjDoc.getDocumentElement().appendChild(typeEl);
Element confEl = prjDoc.createElementNS(PROJECT_NS, "configuration"); // NOI18N
prjDoc.getDocumentElement().appendChild(confEl);
// generate NB Module project type specific elements
Element dataEl = createModuleElement(confEl.getOwnerDocument(), DATA);
confEl.appendChild(dataEl);
Document dataDoc = dataEl.getOwnerDocument();
dataEl.appendChild(createModuleElement(dataDoc, CODE_NAME_BASE, cnb));
Element moduleTypeEl = createTypeElement(dataDoc, moduleType);
if (moduleTypeEl != null) {
dataEl.appendChild(moduleTypeEl);
}
final Element deps = createModuleElement(dataDoc, MODULE_DEPENDENCIES);
for (String depCnb : compileDepsCnbs) {
Element modDepEl = createModuleElement(dataDoc, ProjectXMLManager.DEPENDENCY);
modDepEl.appendChild(createModuleElement(dataDoc, ProjectXMLManager.CODE_NAME_BASE, depCnb));
modDepEl.appendChild(createModuleElement(dataDoc, ProjectXMLManager.BUILD_PREREQUISITE));
modDepEl.appendChild(createModuleElement(dataDoc, ProjectXMLManager.COMPILE_DEPENDENCY));
deps.appendChild(modDepEl);
}
dataEl.appendChild(deps);
dataEl.appendChild(createModuleElement(dataDoc, PUBLIC_PACKAGES));
// store document to disk
ProjectXMLManager.safelyWrite(projectXml, prjDoc);
}
示例8: setElement
import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
* Method setElement
*
* @param element
* @param BaseURI
* @throws XMLSecurityException
*/
public void setElement(Element element, String BaseURI) throws XMLSecurityException {
if (element == null) {
throw new XMLSecurityException("ElementProxy.nullElement");
}
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "setElement(" + element.getTagName() + ", \"" + BaseURI + "\"");
}
this.doc = element.getOwnerDocument();
this.constructionElement = element;
this.baseURI = BaseURI;
}
示例9: testNonstandardDependencies
import org.w3c.dom.Element; //导入方法依赖的package包/类
public void testNonstandardDependencies() throws Exception { // #180717
NbModuleProject p = generateStandaloneModule("m");
Element data = p.getPrimaryConfigurationData();
Element mds = XMLUtil.findElement(data, ProjectXMLManager.MODULE_DEPENDENCIES, NbModuleProject.NAMESPACE_SHARED);
Document doc = mds.getOwnerDocument();
boolean[] Z2 = {false, true};
int i = 0;
for (boolean buildPrerequisite : Z2) {
for (boolean compileDependency : Z2) {
for (boolean runDependency : Z2) {
Element md = (Element) mds.appendChild(doc.createElementNS(NbModuleProject.NAMESPACE_SHARED, ProjectXMLManager.DEPENDENCY));
Element cnb = (Element) md.appendChild(doc.createElementNS(NbModuleProject.NAMESPACE_SHARED, ProjectXMLManager.CODE_NAME_BASE));
cnb.appendChild(doc.createTextNode("dep" + i++));
if (buildPrerequisite) {
md.appendChild(doc.createElementNS(NbModuleProject.NAMESPACE_SHARED, ProjectXMLManager.BUILD_PREREQUISITE));
}
if (compileDependency) {
md.appendChild(doc.createElementNS(NbModuleProject.NAMESPACE_SHARED, ProjectXMLManager.COMPILE_DEPENDENCY));
}
if (runDependency) {
md.appendChild(doc.createElementNS(NbModuleProject.NAMESPACE_SHARED, ProjectXMLManager.RUN_DEPENDENCY));
}
}
}
}
String orig = elementToString(mds);
p.putPrimaryConfigurationData(data);
ProjectXMLManager pxm = new ProjectXMLManager(p);
ModuleDependency extra = new ModuleDependency(new NonexistentModuleEntry(("other")), null, null, true, false);
pxm.addDependency(extra);
pxm.removeDependency("other");
mds = XMLUtil.findElement(p.getPrimaryConfigurationData(), ProjectXMLManager.MODULE_DEPENDENCIES, NbModuleProject.NAMESPACE_SHARED);
assertEquals(orig, elementToString(mds));
}
示例10: preconfigure
import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
public void preconfigure(Element element) throws Exception {
super.preconfigure(element);
try {
NodeList properties = element.getElementsByTagName("property");
// migration of styleContent from String to FormatedContent
Element propElement = (Element) XMLUtils.findNodeByAttributeValue(properties, "name", "styleContent");
if (propElement != null) {
Element valueElement = (Element) XMLUtils.findChildNode(propElement, Node.ELEMENT_NODE);
if (valueElement != null) {
Document document = valueElement.getOwnerDocument();
Object content = XMLUtils.readObjectFromXml(valueElement);
if (content instanceof String) {
FormatedContent formated = new FormatedContent((String) content);
Element newValueElement = (Element)XMLUtils.writeObjectToXml(document, formated);
propElement.replaceChild(newValueElement, valueElement);
hasChanged = true;
Engine.logBeans.warn("(UIStyle) 'styleContent' has been updated for the object \"" + getName() + "\"");
}
}
}
}
catch(Exception e) {
throw new EngineException("Unable to preconfigure the style component \"" + getName() + "\".", e);
}
}
示例11: supplementModuleDocElement
import org.w3c.dom.Element; //导入方法依赖的package包/类
private void supplementModuleDocElement(Element alvisnlpDocElt) throws XPathExpressionException {
Element moduleDocElt = XMLUtils.evaluateElement(moduleDocExpression, alvisnlpDocElt);
if (moduleDocElt == null) {
Document doc = alvisnlpDocElt.getOwnerDocument();
moduleDocElt = XMLUtils.createElement(doc, alvisnlpDocElt, 0, "module-doc");
}
supplementDescriptionElement(moduleDocElt);
supplementParamDocElements(moduleDocElt);
}
示例12: supplementDescriptionElement
import org.w3c.dom.Element; //导入方法依赖的package包/类
private void supplementDescriptionElement(Element moduleDocElt) throws XPathExpressionException {
Element descriptionElt = XMLUtils.evaluateElement(descriptionExpression, moduleDocElt);
if (descriptionElt == null) {
Document doc = moduleDocElt.getOwnerDocument();
descriptionElt = undocumented(doc, moduleDocElt, "description");
}
}
示例13: convertXML
import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
protected DocumentFragment convertXML(Element xmlValue) throws ConverterException {
Document doc = xmlValue.getOwnerDocument();
DocumentFragment result = doc.createDocumentFragment();
for (Node child : XMLUtils.childrenNodes(xmlValue)) {
Node clone = child.cloneNode(true);
result.appendChild(clone);
}
return result;
}
示例14: appendMultiMatchedRow
import org.w3c.dom.Element; //导入方法依赖的package包/类
static void appendMultiMatchedRow(Element table, int colspan, int matchedRows)
{
Document document = table.getOwnerDocument();
Element tr = document.createElement("tr");
table.appendChild(tr);
Element td = document.createElement("td");
td.setAttribute("class", "pass multi");
td.setAttribute("colspan", String.valueOf(colspan));
td.appendChild(document.createTextNode(matchedRows + ResultCell.adaptOnCount(matchedRows, " matched row") + "..."));
tr.appendChild(td);
}
示例15: doc2SystemId
import org.w3c.dom.Element; //导入方法依赖的package包/类
private String doc2SystemId(Element ele) {
String documentURI = null;
/**
* REVISIT: Casting until DOM Level 3 interfaces are available. -- mrglavas
*/
if(ele.getOwnerDocument() instanceof com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOM){
documentURI = ((com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOM) ele.getOwnerDocument()).getDocumentURI();
}
return documentURI != null ? documentURI : (String) fDoc2SystemId.get(ele);
}