private static void writeAttribute(
		StringBuffer buf, 
		String name, 
		String value
	) throws IllegalArgumentException {
		if (isValidXMLAttributeName(name)) {
			buf.append(" ").append(name).append("=\"").append(escapeXMLAttribute(value)).append("\"");
		} else {
			throw new IllegalArgumentException("Invalid attribute name: " + name);
		}
	}