Here you can find the source of copyAttribute(Element sourceElement, String sourceAttrName, Element visualElement, String visualAttrName)
Parameter | Description |
---|---|
sourceElement | the source element |
sourceAttrName | the name of source attribute |
visualElement | the visual element |
visualAttrName | the resulting name of visual attribute |
public static void copyAttribute(Element sourceElement, String sourceAttrName, Element visualElement, String visualAttrName)
//package com.java2s; /******************************************************************************* * Copyright (c) 2007-2014 Red Hat, Inc. * Distributed under license by Red Hat, Inc. All rights reserved. * This program is made available under the terms of the * Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html * * Contributor://from w ww .jav a2s .c o m * Red Hat, Inc. - initial API and implementation ******************************************************************************/ import org.w3c.dom.Element; public class Main { /** * Copies all attributes from source node to visual node. * * @param sourceElement the source element * @param sourceAttrName the name of source attribute * @param visualElement the visual element * @param visualAttrName the resulting name of visual attribute */ public static void copyAttribute(Element sourceElement, String sourceAttrName, Element visualElement, String visualAttrName) { if (sourceElement.hasAttribute(sourceAttrName)) { String attrValue = sourceElement.getAttribute(sourceAttrName); visualElement.setAttribute(visualAttrName, attrValue); } } }