当前位置: 首页>>代码示例>>Java>>正文


Java Element.removeAttribute方法代码示例

本文整理汇总了Java中org.w3c.dom.Element.removeAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Element.removeAttribute方法的具体用法?Java Element.removeAttribute怎么用?Java Element.removeAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.w3c.dom.Element的用法示例。


在下文中一共展示了Element.removeAttribute方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: modifyRootAttributes

import org.w3c.dom.Element; //导入方法依赖的package包/类
/****
 * Method to modify the root attribute (cache) of the XML
 * 
 * @param doc Target document whose root attributes must be modified
 * @param xmlEntity xml entity for the root , it also contains the attributes
 * @throws IOException
 */
public static void modifyRootAttributes(Document doc, XmlEntity xmlEntity) throws IOException {
  if (xmlEntity == null || xmlEntity.getAttributes() == null) {
    return;
  }
  String type = xmlEntity.getType();
  Map<String, String> attributes = xmlEntity.getAttributes();

  Element root = doc.getDocumentElement();
  if (root.getLocalName().equals(type)) {

    for (Entry<String, String> entry : attributes.entrySet()) {
      String attributeName = entry.getKey();
      String attributeValue = entry.getValue();

      // Remove the existing attribute
      String rootAttribute = getAttribute(root, attributeName);
      if (null != rootAttribute) {
        root.removeAttribute(rootAttribute);
      }

      // Add the new attribute with new value
      root.setAttribute(attributeName, attributeValue);
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:33,代码来源:XmlUtils.java

示例2: afterEncode

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Encodes an mxCell and wraps the XML up inside the XML of the user object (inversion).
 */
public Node afterEncode(mxCodec enc, Object obj, Node node) {
  if (obj instanceof mxCell) {
    mxCell cell = (mxCell) obj;

    if (cell.getValue() instanceof Node) {
      // Wraps the graphical annotation up in the
      // user object (inversion) by putting the
      // result of the default encoding into
      // a clone of the user object (node type 1)
      // and returning this cloned user object.
      Element tmp = (Element) node;
      node = enc.getDocument().importNode((Node) cell.getValue(), true);
      node.appendChild(tmp);

      // Moves the id attribute to the outermost
      // XML node, namely the node which denotes
      // the object boundaries in the file.
      String id = tmp.getAttribute("id");
      ((Element) node).setAttribute("id", id);
      tmp.removeAttribute("id");
    }
  }

  return node;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:29,代码来源:mxCellCodec.java

示例3: populateFill

import org.w3c.dom.Element; //导入方法依赖的package包/类
private static void populateFill(Element elt, AbstractCanvasObject shape) {
	Object type = shape.getValue(DrawAttr.PAINT_TYPE);
	if (type == DrawAttr.PAINT_FILL) {
		elt.setAttribute("stroke", "none");
	} else {
		populateStroke(elt, shape);
	}
	if (type == DrawAttr.PAINT_STROKE) {
		elt.setAttribute("fill", "none");
	} else {
		Color fill = shape.getValue(DrawAttr.FILL_COLOR);
		if (colorMatches(fill, Color.BLACK)) {
			elt.removeAttribute("fill");
		} else {
			elt.setAttribute("fill", getColorString(fill));
		}
		if (showOpacity(fill)) {
			elt.setAttribute("fill-opacity", getOpacityString(fill));
		}
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:22,代码来源:SvgCreator.java

示例4: fixupAttrsSingle

import org.w3c.dom.Element; //导入方法依赖的package包/类
private static void fixupAttrsSingle(Element e) throws DOMException {
    removeXmlBase(e);
    Map<String, String> replace = new HashMap<String, String>();
    NamedNodeMap attrs = e.getAttributes();
    for (int j = 0; j < attrs.getLength(); j++) {
        Attr attr = (Attr) attrs.item(j);
        if (attr.getNamespaceURI() == null && !attr.getName().equals("xmlns")) { // NOI18N
            replace.put(attr.getName(), attr.getValue());
        }
    }
    for (Map.Entry<String, String> entry : replace.entrySet()) {
        e.removeAttribute(entry.getKey());
        e.setAttributeNS(null, entry.getKey(), entry.getValue());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:XMLUtil.java

示例5: afterEncode

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Encodes an mxCell and wraps the XML up inside the
 * XML of the user object (inversion).
 */
public Node afterEncode(mxCodec enc, Object obj, Node node)
{
	if (obj instanceof mxCell)
	{
		mxCell cell = (mxCell) obj;

		if (cell.getValue() instanceof Node)
		{
			// Wraps the graphical annotation up in the
			// user object (inversion) by putting the
			// result of the default encoding into
			// a clone of the user object (node type 1)
			// and returning this cloned user object.
			Element tmp = (Element) node;
			node = enc.getDocument().importNode((Node) cell.getValue(),
					true);
			node.appendChild(tmp);

			// Moves the id attribute to the outermost
			// XML node, namely the node which denotes
			// the object boundaries in the file.
			String id = tmp.getAttribute("id");
			((Element) node).setAttribute("id", id);
			tmp.removeAttribute("id");
		}
	}

	return node;
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:34,代码来源:mxCellCodec.java

示例6: removeXmlBase

import org.w3c.dom.Element; //导入方法依赖的package包/类
private static void removeXmlBase(Element e) {
    e.removeAttributeNS("http://www.w3.org/XML/1998/namespace", "base"); // NOI18N
    e.removeAttribute("xml:base"); // NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:XMLUtil.java

示例7: removePercentageAttributes

import org.w3c.dom.Element; //导入方法依赖的package包/类
private void removePercentageAttributes(Element element) {
    element.removeAttribute(BillingShareResultXmlTags.ATTRIBUTE_NAME_BROKER_REVENUE_SHARE_PERCENTAGE);
    element.removeAttribute(BillingShareResultXmlTags.ATTRIBUTE_NAME_RESELLER_REVENUE_SHARE_PERCENTAGE);
    element.removeAttribute(BillingShareResultXmlTags.ATTRIBUTE_NAME_MARKETPLACE_REVENUE_SHARE_PERCENTAGE);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:6,代码来源:MigrationBillingSharesResultOperatorRevShare.java

示例8: cleanToolsReferences

import org.w3c.dom.Element; //导入方法依赖的package包/类
private static MergingReport.Result cleanToolsReferences(
        Element element,
        ILogger logger) {

    NamedNodeMap namedNodeMap = element.getAttributes();
    if (namedNodeMap != null) {
        // make a copy of the original list of attributes as we will remove some during this
        // process.
        List<Node> attributes = new ArrayList<Node>();
        for (int i = 0; i < namedNodeMap.getLength(); i++) {
            attributes.add(namedNodeMap.item(i));
        }
        for (Node attribute : attributes) {
            if (SdkConstants.TOOLS_URI.equals(attribute.getNamespaceURI())) {
                // we need to special case when the element contained tools:node="remove"
                // since it also needs to be deleted unless it had a selector.
                // if this is ools:node="removeAll", we always delete the element whether or
                // not there is a tools:selector.
                boolean hasSelector = namedNodeMap.getNamedItemNS(
                        SdkConstants.TOOLS_URI, "selector") != null;
                if (attribute.getLocalName().equals(NodeOperationType.NODE_LOCAL_NAME)
                        && (attribute.getNodeValue().equals(REMOVE_ALL_OPERATION_XML_MAME)
                            || (attribute.getNodeValue().equals(REMOVE_OPERATION_XML_MAME))
                                && !hasSelector)) {

                    if (element.getParentNode().getNodeType() == Node.DOCUMENT_NODE) {
                        logger.error(null /* Throwable */,
                                String.format(
                                    "tools:node=\"%1$s\" not allowed on top level %2$s element",
                                    attribute.getNodeValue(),
                                    XmlNode.unwrapName(element)));
                        return ERROR;
                    } else {
                        element.getParentNode().removeChild(element);
                    }
                } else {
                    // anything else, we just clean the attribute.
                    element.removeAttributeNS(
                            attribute.getNamespaceURI(), attribute.getLocalName());
                }
            }
            // this could also be the xmlns:tools declaration.
            if (attribute.getNodeName().startsWith(SdkConstants.XMLNS_PREFIX)
                && SdkConstants.TOOLS_URI.equals(attribute.getNodeValue())) {
                element.removeAttribute(attribute.getNodeName());
            }
        }
    }
    // make a copy of the element children since we will be removing some during
    // this process, we don't want side effects.
    NodeList childNodes = element.getChildNodes();
    ImmutableList.Builder<Element> childElements = ImmutableList.builder();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node node = childNodes.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            childElements.add((Element) node);
        }
    }
    for (Element childElement : childElements.build()) {
        if (cleanToolsReferences(childElement, logger) == ERROR) {
            return ERROR;
        }
    }
    return MergingReport.Result.SUCCESS;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:66,代码来源:ToolsInstructionsCleaner.java


注:本文中的org.w3c.dom.Element.removeAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。