本文整理了Java中org.jdom2.Element.removeAttribute()
方法的一些代码示例,展示了Element.removeAttribute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.removeAttribute()
方法的具体详情如下:
包路径:org.jdom2.Element
类名称:Element
方法名:removeAttribute
[英]This removes the attribute with the given name and within no namespace. If no such attribute exists, this method does nothing.
[中]这将删除具有给定名称且不在名称空间内的属性。如果不存在此类属性,则此方法不执行任何操作。
代码示例来源:origin: org.jdom/jdom
/**
* <p>
* This removes the attribute with the given name and within no
* namespace. If no such attribute exists, this method does nothing.
* </p>
*
* @param attname name of attribute to remove
* @return whether the attribute was removed
*/
public boolean removeAttribute(final String attname) {
return removeAttribute(attname, Namespace.NO_NAMESPACE);
}
代码示例来源:origin: org.jdom/jdom
/**
* Detach this Attribute from its parent.
* @return this Attribute (detached).
*/
public Attribute detach() {
if (parent != null) {
parent.removeAttribute(this);
}
return this;
}
代码示例来源:origin: org.codehaus.plexus/plexus-component-metadata
/**
* @see org.jdom2.Element#removeAttribute(org.jdom2.Attribute)
* @param attribute {@link Attribute}
* @return true/false.
*/
public boolean removeAttribute( Attribute attribute )
{
return element.removeAttribute( attribute );
}
代码示例来源:origin: org.codehaus.plexus/plexus-component-metadata
/**
* @see org.jdom2.Element#removeAttribute(java.lang.String,org.jdom2.Namespace)
* @param name The name of the attribute.
* @param ns The {@link Namespace}
* @return true/false.
*/
public boolean removeAttribute( String name, Namespace ns )
{
return element.removeAttribute( name, ns );
}
代码示例来源:origin: org.codehaus.plexus/plexus-component-metadata
/**
* @see org.jdom2.Element#removeAttribute(java.lang.String)
* @param name The mame of the attribute.
* @return true/false.
*/
public boolean removeAttribute( String name )
{
return element.removeAttribute( name );
}
代码示例来源:origin: org.mycore/mycore-mods
private Element cloneRelatedItem(Element relatedItem) {
Element mods = relatedItem.clone();
mods.setName("mods");
mods.removeAttribute("type");
mods.removeAttribute("href", MCRConstants.XLINK_NAMESPACE);
mods.removeAttribute("type", MCRConstants.XLINK_NAMESPACE);
mods.removeChildren("part", MCRConstants.MODS_NAMESPACE);
return mods;
}
代码示例来源:origin: io.wcm/io.wcm.handler.commons
/**
* <p>
* This sets an attribute value for this element. Any existing attribute with the same name and namespace URI is
* removed.
* </p>
* @param name name of the attribute to set
* @param value value of the attribute to set
* @return this element modified
* @throws org.jdom2.IllegalNameException if the given name is illegal as an attribute name.
* @throws org.jdom2.IllegalDataException if the given attribute value is illegal character data
* (as determined by {@link org.jdom2.Verifier#checkCharacterData}).
*/
@Override
public final org.jdom2.Element setAttribute(String name, String value) {
// remove attribute if value is set to null
if (value == null) {
super.removeAttribute(name);
return this;
}
else {
return super.setAttribute(name, cleanUpString(value));
}
}
代码示例来源:origin: org.mycore/mycore-xeditor
private boolean handleBeforeAfter(Element container, Element includeRule, String attributeName, int offset,
int defaultPos) {
String refID = includeRule.getAttributeValue(attributeName);
if (refID != null) {
includeRule.removeAttribute(attributeName);
Element parent = container;
int pos = defaultPos;
Optional<Element> neighbor = findDescendant(container, refID);
if (neighbor.isPresent()) {
Element n = neighbor.get();
parent = n.getParentElement();
List<Element> children = parent.getChildren();
pos = children.indexOf(n) + offset;
}
LOGGER.debug("including " + Arrays.toString(includeRule.getAttributes().toArray()) + " at pos " + pos);
parent.getChildren().add(pos, includeRule.clone());
}
return refID != null;
}
代码示例来源:origin: io.wcm/io.wcm.handler.commons
/**
* <p>
* This sets an attribute value for this element. Any existing attribute with the same name and namespace URI is
* removed.
* </p>
* @param name name of the attribute to set
* @param value value of the attribute to set
* @param ns namespace of the attribute to set
* @return this element modified
* @throws org.jdom2.IllegalNameException if the given name is illegal as an attribute name, or if the namespace
* is an unprefixed default namespace
* @throws org.jdom2.IllegalDataException if the given attribute value is illegal character data (as determined
* by {@link org.jdom2.Verifier#checkCharacterData}).
* @throws org.jdom2.IllegalAddException if the attribute namespace prefix collides with another namespace
* prefix on the element.
*/
@Override
public final org.jdom2.Element setAttribute(String name, String value, Namespace ns) {
// remove attribute if value is set to null
if (value == null) {
super.removeAttribute(name, ns);
return this;
}
else {
return super.setAttribute(name, cleanUpString(value), ns);
}
}
代码示例来源:origin: org.mycore/mycore-xeditor
public void undo(MCRChangeData data) {
Attribute attribute = data.getAttribute();
data.getContext().removeAttribute(attribute.getName(), attribute.getNamespace());
}
}
代码示例来源:origin: pwm-project/pwm
private static void updateMetaData( final Element settingElement, final UserIdentity userIdentity )
{
final Element settingsElement = settingElement.getDocument().getRootElement().getChild( XML_ELEMENT_SETTINGS );
settingElement.setAttribute( XML_ATTRIBUTE_MODIFY_TIME, JavaHelper.toIsoDate( Instant.now() ) );
settingsElement.setAttribute( XML_ATTRIBUTE_MODIFY_TIME, JavaHelper.toIsoDate( Instant.now() ) );
settingElement.removeAttribute( XML_ATTRIBUTE_MODIFY_USER );
settingsElement.removeAttribute( XML_ATTRIBUTE_MODIFY_USER );
if ( userIdentity != null )
{
settingElement.setAttribute( XML_ATTRIBUTE_MODIFY_USER, userIdentity.toDelimitedKey() );
settingsElement.setAttribute( XML_ATTRIBUTE_MODIFY_USER, userIdentity.toDelimitedKey() );
}
}
代码示例来源:origin: org.mycore/mycore-xeditor
public void undo(MCRChangeData data) {
Attribute attribute = data.getAttribute();
data.getContext().removeAttribute(attribute.getName(), attribute.getNamespace());
data.getContext().setAttribute(attribute);
}
}
代码示例来源:origin: org.mycore/mycore-wcms2
/**
* Converts the navigation.xml to the old format.
*/
private static byte[] convertToOldFormat(byte[] xml) throws JDOMException, IOException {
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(new ByteArrayInputStream(xml));
Element rootElement = doc.getRootElement();
rootElement.setAttribute("href", rootElement.getName());
List<Element> children = rootElement.getChildren();
for (Element menu : children) {
String id = menu.getAttributeValue("id");
menu.setName(id);
menu.setAttribute("href", id);
menu.removeAttribute("id");
}
XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());
ByteArrayOutputStream bout = new ByteArrayOutputStream(xml.length);
out.output(doc, bout);
return bout.toByteArray();
}
代码示例来源:origin: Unidata/thredds
public Element makeNetcdfElement(NetcdfFile ncFile, String location) {
Element rootElem = makeGroupElement(ncFile.getRootGroup());
// rootElem isn't just like any other group element; we must undo some of the changes made to it in writeGroup().
rootElem.setName("netcdf"); // Was "group".
rootElem.removeAttribute("name"); // This attribute is not defined on the root "netcdf" element.
rootElem.addNamespaceDeclaration(namespace);
if (null == location)
location = ncFile.getLocation();
if (null != location) {
rootElem.setAttribute("location", URLnaming.canonicalizeWrite(location));
}
if (null != ncFile.getId())
rootElem.setAttribute("id", ncFile.getId());
if (null != ncFile.getTitle())
rootElem.setAttribute("title", ncFile.getTitle());
return rootElem;
}
代码示例来源:origin: Vhati/Slipstream-Mod-Manager
handled = true;
for ( Attribute attrib : cmdNode.getAttributes() ) {
contextNode.removeAttribute( attrib.getName() );
代码示例来源:origin: org.apache.marmotta/sesame-tools-rio-rss
public void populateItem(Item item, Element eItem, int index) {
super.populateItem(item,eItem, index);
Element eDescription = eItem.getChild("description",getFeedNamespace());
if (eDescription != null) eDescription.removeAttribute("type");
String author = item.getAuthor();
if (author != null) {
eItem.addContent(generateSimpleElement("author", author));
}
String comments = item.getComments();
if (comments != null) {
eItem.addContent(generateSimpleElement("comments", comments));
}
Guid guid = item.getGuid();
if (guid != null) {
Element eGuid = generateSimpleElement("guid",guid.getValue());
if (!guid.isPermaLink()) {
eGuid.setAttribute("isPermaLink", "false");
}
eItem.addContent(eGuid);
}
}
代码示例来源:origin: rometools/rome
@Override
public void populateItem(final Item item, final Element eItem, final int index) {
super.populateItem(item, eItem, index);
final Element description = eItem.getChild("description", getFeedNamespace());
if (description != null) {
description.removeAttribute("type");
}
final String author = item.getAuthor();
if (author != null) {
eItem.addContent(generateSimpleElement("author", author));
}
final String comments = item.getComments();
if (comments != null) {
eItem.addContent(generateSimpleElement("comments", comments));
}
final Guid guid = item.getGuid();
if (guid != null) {
final Element eGuid = generateSimpleElement("guid", guid.getValue());
if (!guid.isPermaLink()) {
eGuid.setAttribute("isPermaLink", "false");
}
eItem.addContent(eGuid);
}
}
代码示例来源:origin: apache/marmotta
public void populateItem(Item item, Element eItem, int index) {
super.populateItem(item,eItem, index);
Element eDescription = eItem.getChild("description",getFeedNamespace());
if (eDescription != null) eDescription.removeAttribute("type");
String author = item.getAuthor();
if (author != null) {
eItem.addContent(generateSimpleElement("author", author));
}
String comments = item.getComments();
if (comments != null) {
eItem.addContent(generateSimpleElement("comments", comments));
}
Guid guid = item.getGuid();
if (guid != null) {
Element eGuid = generateSimpleElement("guid",guid.getValue());
if (!guid.isPermaLink()) {
eGuid.setAttribute("isPermaLink", "false");
}
eItem.addContent(eGuid);
}
}
代码示例来源:origin: com.rometools/rome
@Override
public void populateItem(final Item item, final Element eItem, final int index) {
super.populateItem(item, eItem, index);
final Element description = eItem.getChild("description", getFeedNamespace());
if (description != null) {
description.removeAttribute("type");
}
final String author = item.getAuthor();
if (author != null) {
eItem.addContent(generateSimpleElement("author", author));
}
final String comments = item.getComments();
if (comments != null) {
eItem.addContent(generateSimpleElement("comments", comments));
}
final Guid guid = item.getGuid();
if (guid != null) {
final Element eGuid = generateSimpleElement("guid", guid.getValue());
if (!guid.isPermaLink()) {
eGuid.setAttribute("isPermaLink", "false");
}
eItem.addContent(eGuid);
}
}
内容来源于网络,如有侵权,请联系作者删除!