Example usage for org.w3c.dom Element removeAttribute

List of usage examples for org.w3c.dom Element removeAttribute

Introduction

In this page you can find the example usage for org.w3c.dom Element removeAttribute.

Prototype

public void removeAttribute(String name) throws DOMException;

Source Link

Document

Removes an attribute by name.

Usage

From source file:com.codename1.android.AndroidLayoutImporter.java

private void convertListView(Element inputSrcElement, Element out) {
    out.removeAttribute("layout");
    out.setAttribute("type", "List");

}

From source file:com.codename1.android.AndroidLayoutImporter.java

private void convertProgressBar(Element inputSrcElement, Element out) {
    out.removeAttribute("layout");
    out.setAttribute("type", "Slider");
}

From source file:com.codename1.android.AndroidLayoutImporter.java

private void convertTextView(Element inputSrcElement, Element out) {
    out.removeAttribute("layout");
    if ("true".equals(inputSrcElement.getAttributeNS(NS_ANDROID, "editable"))) {
        if ("true".equals(inputSrcElement.getAttributeNS(NS_ANDROID, "singleLine"))) {
            out.setAttribute("type", "TextField");
        } else {/*from   www .  j  a va  2  s  .c om*/
            out.setAttribute("type", "TextArea");
        }
    } else {
        if ("true".equals(inputSrcElement.getAttributeNS(NS_ANDROID, "singleLine"))) {
            out.setAttribute("type", "Label");
        } else {
            out.setAttribute("type", "SpanLabel");
        }
    }
    if (inputSrcElement.hasAttributeNS(NS_ANDROID, "text")) {
        out.setAttribute("text", parseText(inputSrcElement.getAttributeNS(NS_ANDROID, "text")));
        if (out.getAttribute("type").equals("SpanLabel") && out.getAttribute("text").length() < 30) {

            out.setAttribute("type", "Label");
        }
    }

}

From source file:com.codename1.android.AndroidLayoutImporter.java

private void convertButton(Element inputSrcElement, Element out) {
    out.removeAttribute("layout");
    out.setAttribute("type", "Button");
    //System.out.println("Converting button "+inputSrcElement);
    int attlen = inputSrcElement.getAttributes().getLength();
    for (int i = 0; i < attlen; i++) {
        Node n = inputSrcElement.getAttributes().item(i);
        //System.out.println("Namespace is "+n.getNamespaceURI());
        //System.out.println("Node "+i+"="+n);
    }/*  w  w  w.j  a  v  a2  s . c om*/

    //System.out.println("Text is "+inputSrcElement.getAttributeNS(NS_ANDROID, "text"));
    if (inputSrcElement.hasAttributeNS(NS_ANDROID, "text")) {
        out.setAttribute("text", parseText(inputSrcElement.getAttributeNS(NS_ANDROID, "text")));
    }

}

From source file:com.codename1.android.AndroidLayoutImporter.java

private void convertSpinner(Element inputSrcElement, Element out) {
    out.setAttribute("type", "GenericSpinner");
    out.removeAttribute("layout");
}

From source file:com.codename1.android.AndroidLayoutImporter.java

private void convertImageView(Element inputSrcElement, Element out) {
    out.removeAttribute("layout");
    out.setAttribute("type", "Label");
}

From source file:com.codename1.android.AndroidLayoutImporter.java

private void convertSeekBar(Element inputSrcElement, Element out) {
    out.removeAttribute("layout");
    out.setAttribute("type", "Slider");
}

From source file:net.wastl.webmail.xml.XMLUserData.java

/**
 * Does nothing in case of failure./*from w w w .  j  a  v a  2  s.c  om*/
 */
public void setDefaultEmail(String s) {
    NodeList nl = getNodeListXPath("/USERDATA/EMAIL/ADDY");
    for (int i = 0; i < nl.getLength(); i++) {
        Element email = (Element) nl.item(i);
        // Be sure there is no other 'default'
        email.removeAttribute("default");
    }

    Element email = null;
    String xPathString = "/USERDATA/EMAIL/ADDY[./text() = '" + s + "']";
    try {
        email = (Element) getNodeXPath(xPathString);
    } catch (TransformerException te) {
        log.error("Failed to get extract node for XPath '" + xPathString + "'", te);
        XMLCommon.dumpXML(log, xPathString, root);
        return;
    }
    email.setAttribute("default", "yes");
    invalidateCache();
}

From source file:org.apache.geode.management.internal.configuration.utils.XmlUtils.java

/****
 * Method to modify the root attribute (cache) of the XML
 * //from   w w w. ja  v a  2s .  c o m
 * @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) {
    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);
        }
    }
}

From source file:org.apache.openaz.xacml.pdp.policy.dom.DOMAttributeAssignmentExpression.java

public static boolean repair(Node nodeAttributeAssignmentExpression) throws DOMStructureException {
    Element elementAttributeAssignmentExpression = DOMUtil.getElement(nodeAttributeAssignmentExpression);
    boolean result = false;

    if (DOMUtil.getFirstChildElement(elementAttributeAssignmentExpression) == null) {
        /*/*w ww .  ja  v a  2  s . c o m*/
         * See if we can repair the <AttributeAssignmentExpression
         * DataType="">string</AttributeAssignmentExpression> pattern
         */
        Identifier identifier = DOMUtil.getIdentifierAttribute(elementAttributeAssignmentExpression,
                XACML3.ATTRIBUTE_DATATYPE);
        String textContent = elementAttributeAssignmentExpression.getTextContent();
        if (textContent != null) {
            textContent = textContent.trim();
        }
        if (textContent != null && textContent.length() > 0 && identifier != null) {
            Element attributeValue = elementAttributeAssignmentExpression.getOwnerDocument()
                    .createElementNS(XACML3.XMLNS, XACML3.ELEMENT_ATTRIBUTEVALUE);
            attributeValue.setAttribute(XACML3.ATTRIBUTE_DATATYPE, identifier.stringValue());
            attributeValue.setTextContent(textContent);
            logger.warn("Adding a new AttributeValue using the DataType from the AttributeAssignment");
            elementAttributeAssignmentExpression.removeAttribute(XACML3.ATTRIBUTE_DATATYPE);
            while (elementAttributeAssignmentExpression.hasChildNodes()) {
                elementAttributeAssignmentExpression
                        .removeChild(elementAttributeAssignmentExpression.getFirstChild());
            }
            elementAttributeAssignmentExpression.appendChild(attributeValue);
            result = true;
        } else {
            throw DOMUtil.newMissingElementException(elementAttributeAssignmentExpression, XACML3.XMLNS,
                    XACML3.ELEMENT_EXPRESSION);
        }
    }
    result = DOMUtil.repairIdentifierAttribute(elementAttributeAssignmentExpression,
            XACML3.ATTRIBUTE_ATTRIBUTEID, logger) || result;

    return result;
}