Java Code Examples for com.intellij.psi.xml.XmlAttribute#setValue()

The following examples show how to use com.intellij.psi.xml.XmlAttribute#setValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MuleSchemaUtils.java    From mule-intellij-plugins with Apache License 2.0 6 votes vote down vote up
public static void insertSchemaLocationLookup(XmlFile xmlFile, String namespace, String locationLookup) {
    final XmlTag rootTag = xmlFile.getRootTag();
    if (rootTag == null)
        return;
    final XmlAttribute attribute = rootTag.getAttribute("xsi:schemaLocation", HTTP_WWW_W3_ORG_2001_XMLSCHEMA);
    if (attribute != null) {
        final String value = attribute.getValue();
        attribute.setValue(value + "\n\t\t\t" + namespace + " " + locationLookup);
    } else {
        final XmlElementFactory elementFactory = XmlElementFactory.getInstance(xmlFile.getProject());
        final XmlAttribute schemaLocation = elementFactory.createXmlAttribute("xsi:schemaLocation", XmlUtil.XML_SCHEMA_INSTANCE_URI);
        schemaLocation.setValue(namespace + " " + locationLookup);
        rootTag.add(schemaLocation);
    }

}
 
Example 2
Source File: NMEBuildDirectoryInspection.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
private void appendValue(XmlTag element, String release) {
  XmlAttribute outAttribute = ((XmlTag)element).getAttribute("value");
  if (outAttribute != null) {
    outAttribute.setValue(outAttribute.getValue() + "/" + release);
  }
}