本文整理了Java中org.jdom2.Element.removeNamespaceDeclaration()
方法的一些代码示例,展示了Element.removeNamespaceDeclaration()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.removeNamespaceDeclaration()
方法的具体详情如下:
包路径:org.jdom2.Element
类名称:Element
方法名:removeNamespaceDeclaration
[英]Removes an additional namespace declarations from this element. This should not be used to remove the declaration for this element itself; that should be handled in the construction of the element. Instead, this is for removing namespace declarations on the element not relating directly to itself. If the declaration is not present, this method does nothing.
[中]从此元素中删除其他命名空间声明。这不应用于删除此元素本身的声明;这应该在元素的构造中处理。相反,这是为了删除与自身不直接相关的元素上的名称空间声明。如果声明不存在,则此方法不执行任何操作。
代码示例来源:origin: org.codehaus.plexus/plexus-component-metadata
/**
* @see org.jdom2.Element#removeNamespaceDeclaration(org.jdom2.Namespace)
* @param additionalNamespace {@link Namespace}.
*/
public void removeNamespaceDeclaration( Namespace additionalNamespace )
{
element.removeNamespaceDeclaration( additionalNamespace );
}
代码示例来源:origin: rometools/rome
/**
* Purging unused declarations is less optimal, performance-wise, than never adding them in the
* first place. So, we should still ask the ROME guys to fix their code (not adding dozens of
* unnecessary module declarations). Having said that: purging them here, before XML generation,
* is more efficient than parsing and re-molding the XML after ROME generates it.
* <p/>
* Note that the calling app could still add declarations/modules to the Feed tree after this.
* Which is fine. But those modules are then responsible for crawling to the root of the tree,
* at generate() time, to make sure their namespace declarations are present.
*/
protected static void purgeUnusedNamespaceDeclarations(final Element root) {
final Set<String> usedPrefixes = new HashSet<String>();
collectUsedPrefixes(root, usedPrefixes);
final List<Namespace> list = root.getAdditionalNamespaces();
final List<Namespace> additionalNamespaces = new ArrayList<Namespace>();
additionalNamespaces.addAll(list); // the duplication will prevent a
// ConcurrentModificationException
// below
for (final Namespace ns : additionalNamespaces) {
final String prefix = ns.getPrefix();
if (prefix != null && prefix.length() > 0 && !usedPrefixes.contains(prefix)) {
root.removeNamespaceDeclaration(ns);
}
}
}
代码示例来源:origin: org.apache.marmotta/sesame-tools-rio-rss
/**
* Purging unused declarations is less optimal, performance-wise, than never adding them in the first place. So, we
* should still ask the ROME guys to fix their code (not adding dozens of unnecessary module declarations). Having
* said that: purging them here, before XML generation, is more efficient than parsing and re-molding the XML after
* ROME generates it.
* <p/>
* Note that the calling app could still add declarations/modules to the Feed tree after this. Which is fine. But
* those modules are then responsible for crawling to the root of the tree, at generate() time, to make sure their
* namespace declarations are present.
*/
protected static void purgeUnusedNamespaceDeclarations(Element root) {
java.util.Set usedPrefixes = new java.util.HashSet();
collectUsedPrefixes(root, usedPrefixes);
List list = root.getAdditionalNamespaces();
List additionalNamespaces = new java.util.ArrayList();
additionalNamespaces.addAll(list); // the duplication will prevent a ConcurrentModificationException below
for (int i = 0; i < additionalNamespaces.size(); i++) {
Namespace ns = (Namespace) additionalNamespaces.get(i);
String prefix = ns.getPrefix();
if (prefix != null && prefix.length() > 0 && !usedPrefixes.contains(prefix)) {
root.removeNamespaceDeclaration(ns);
}
}
}
代码示例来源:origin: apache/marmotta
/**
* Purging unused declarations is less optimal, performance-wise, than never adding them in the first place. So, we
* should still ask the ROME guys to fix their code (not adding dozens of unnecessary module declarations). Having
* said that: purging them here, before XML generation, is more efficient than parsing and re-molding the XML after
* ROME generates it.
* <p/>
* Note that the calling app could still add declarations/modules to the Feed tree after this. Which is fine. But
* those modules are then responsible for crawling to the root of the tree, at generate() time, to make sure their
* namespace declarations are present.
*/
protected static void purgeUnusedNamespaceDeclarations(Element root) {
java.util.Set usedPrefixes = new java.util.HashSet();
collectUsedPrefixes(root, usedPrefixes);
List list = root.getAdditionalNamespaces();
List additionalNamespaces = new java.util.ArrayList();
additionalNamespaces.addAll(list); // the duplication will prevent a ConcurrentModificationException below
for (Object additionalNamespace : additionalNamespaces) {
Namespace ns = (Namespace) additionalNamespace;
String prefix = ns.getPrefix();
if (prefix != null && prefix.length() > 0 && !usedPrefixes.contains(prefix)) {
root.removeNamespaceDeclaration(ns);
}
}
}
代码示例来源:origin: com.rometools/rome
/**
* Purging unused declarations is less optimal, performance-wise, than never adding them in the
* first place. So, we should still ask the ROME guys to fix their code (not adding dozens of
* unnecessary module declarations). Having said that: purging them here, before XML generation,
* is more efficient than parsing and re-molding the XML after ROME generates it.
* <p/>
* Note that the calling app could still add declarations/modules to the Feed tree after this.
* Which is fine. But those modules are then responsible for crawling to the root of the tree,
* at generate() time, to make sure their namespace declarations are present.
*/
protected static void purgeUnusedNamespaceDeclarations(final Element root) {
final Set<String> usedPrefixes = new HashSet<String>();
collectUsedPrefixes(root, usedPrefixes);
final List<Namespace> list = root.getAdditionalNamespaces();
final List<Namespace> additionalNamespaces = new ArrayList<Namespace>();
additionalNamespaces.addAll(list); // the duplication will prevent a
// ConcurrentModificationException
// below
for (final Namespace ns : additionalNamespaces) {
final String prefix = ns.getPrefix();
if (prefix != null && prefix.length() > 0 && !usedPrefixes.contains(prefix)) {
root.removeNamespaceDeclaration(ns);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!