Build XPath expression for elements with attribute name and optional value.

@param name attribute name,
@param value optional attribute value.
@return XPath expression.
423659
String buildAttrXPath(String name, String... value) {
		StringBuilder sb = new StringBuilder();
		sb.append("//*[@");
		sb.append(name);
		if (value.length == 1) {
			sb.append("='");
			sb.append(value[0]);
			sb.append("'");
		}
		sb.append("]");
		return sb.toString();
	}
1264021
public JobXMLDescriptor addNamespace(String name, String value)
   {
      model.attribute(name, value);
      return this;
   }
1347545
public static XPathCheckResult parse(String value) {
        XPathCheckResult parsed = new XPathCheckResult();
        parsed.result = value;
        return parsed;
    }
281285
protected final Element generateSimpleElement(final String name, final String value) {
        final Element element = new Element(name, getDCNamespace());
        element.addContent(value);
        return element;
    }
806074
@XmlElementDecl(namespace = "urn:oasis:names:tc:xacml:2.0:policy:schema:os", name = "AttributeSelector", substitutionHeadNamespace = "urn:oasis:names:tc:xacml:2.0:policy:schema:os", substitutionHeadName = "Expression")
    public JAXBElement<AttributeSelectorType> createAttributeSelector(AttributeSelectorType value) {
        return new JAXBElement<AttributeSelectorType>(_AttributeSelector_QNAME, AttributeSelectorType.class, null, value);
    }
497354
public void addAttribute(final String name, final String value) {
        ArgUtils.notEmpty(name, "name");
        removeAttribute(name);
        this.attributes.add(AttributeInfo.create(name, value));
    }
593060
public static String createPropertyFilter(String name, String value) {
        assert name.matches("[^=><~()]+");

        StringBuilder builder = new StringBuilder(name.length() + 3 + (value == null ? 0 : value.length() * 2));
        builder.append('(').append(name).append('=');

        int begin = 0;
        if (value != null) {
            for (int i = 0; i < value.length(); i++) {
                if ("\\*()".indexOf(value.charAt(i)) != -1) {
                    builder.append(value, begin, i).append('\\');
                    begin = i;
                }
            }

            return builder.append(value, begin, value.length()).append(')').toString();
        } else {
            return builder.append(')').toString();
        }
    }
1190329
def child_xpath(ns, element_name, attributes=nil)
      ns_uri = ns.is_a?(Namespace) ? ns.uri : ns
      unless !attributes.nil? && attributes.is_a?(Hash)
        "child::*[local-name()='#{element_name}' and namespace-uri()='#{ns_uri}']"
      else
        attr_str = attributes.collect{|key, val| "@#{key.to_s}='#{val}'"}.join(' and ')
        "child::*[local-name()='#{element_name}' and namespace-uri()='#{ns_uri}' and #{attr_str}]"
      end
    end
237670
def element_for_attribute(name, namespace='')
      val = instance_values[name]
      return "" if val == nil
      "<%s:%s val='%s'/>" % [namespace, Axlsx::camel(name, false), val]
    end
1000746
public boolean hasAttribute(String name)
  {
    return DTM.NULL != dtm.getAttributeNode(node,null,name);
  }
1116376
private <T extends XSString> T createXSString(Class<T> clazz, String value) {
    if (value == null) {
      return null;
    }
    QName elementName = null;
    String localName = null;
    try {
      elementName = (QName) clazz.getDeclaredField("DEFAULT_ELEMENT_NAME").get(null);
      localName = (String) clazz.getDeclaredField("DEFAULT_ELEMENT_LOCAL_NAME").get(null);
    }
    catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException | SecurityException e) {
      throw new RuntimeException(e);
    }
    XMLObjectBuilder<? extends XMLObject> builder = XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(elementName);
    Object object = builder.buildObject(new QName(this.getElementQName().getNamespaceURI(), localName, this.getElementQName().getPrefix()));
    T xsstring = clazz.cast(object);
    xsstring.setValue(value);
    return xsstring;
  }
1126120
@NotNull
    public static XPath createXPath(@Nullable final String... values) {
        final NamespaceContext context = new NamespaceContextMap(values);
        final XPath xPath = XPathFactory.newInstance().newXPath();
        xPath.setNamespaceContext(context);
        return xPath;
    }
19002
public static function attr($name, $value = null)
    {
        if (is_string($name)) {
            $name = [$name => $value];
        }

        return HtmlBuilder::buildAttributes($name);
    }
1008112
public Document findXMLResource(String name) {
    URL url = this.getClass().getResource(name);
    DocumentBuilderFactory docFactory = DocumentBuilderFactory
            .newInstance();
    docFactory.setNamespaceAware(true);
	// Fortify Mod: Disable entity expansion to foil External Entity Injections
	docFactory.setExpandEntityReferences(false);
    Document doc = null;
    try {
      DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
      doc = docBuilder.parse(url.toURI().toString());
    } catch (Exception e) {
      LOGR.log(Level.WARNING, "Failed to parse classpath resource "
              + name, e);
    }
    return doc;
  }
561857
private String appendXmlEndingTag(String value) {
        StringBuilder sb = new StringBuilder();
        sb.append("</").append(value).append(">");

        return sb.toString();
    }
592972
public static Node asNode(String nodeName, Node node, XPath xpath)
            throws XPathExpressionException {
        if (node == null) return null;
        return (Node) xpath.evaluate(nodeName, node, XPathConstants.NODE);
    }
556171
def get_attribute_by_name(el, name, default=None):
        """"""

        value = default
        if el._is_xml:
            try:
                value = el.attrs[name]
            except KeyError:
                pass
        else:
            for k, v in el.attrs.items():
                if util.lower(k) == name:
                    value = v
                    break
        return value