/** * <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); }
/** * Detach this Attribute from its parent. * @return this Attribute (detached). */ public Attribute detach() { if (parent != null) { parent.removeAttribute(this); } return this; }
/** * @see org.jdom2.Element#removeAttribute(org.jdom2.Attribute) * @param attribute {@link Attribute} * @return true/false. */ public boolean removeAttribute( Attribute attribute ) { return element.removeAttribute( attribute ); }
/** * @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 ); }
/** * @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 ); }
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; }
/** * <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)); } }
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; }
/** * <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); } }
public void undo(MCRChangeData data) { Attribute attribute = data.getAttribute(); data.getContext().removeAttribute(attribute.getName(), attribute.getNamespace()); } }
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() ); } }
public void undo(MCRChangeData data) { Attribute attribute = data.getAttribute(); data.getContext().removeAttribute(attribute.getName(), attribute.getNamespace()); data.getContext().setAttribute(attribute); } }
/** * 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(); }
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; }
handled = true; for ( Attribute attrib : cmdNode.getAttributes() ) { contextNode.removeAttribute( attrib.getName() );
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); } }
@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); } }
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); } }
@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); } }