Converts a null value into an XML element
484407
def convert_none(key, val, attr_type, attr={}, cdata=False):
    """"""
    LOG.info('Inside convert_none(): key="%s"' % (unicode_me(key)))

    key, attr = make_valid_xml_name(key, attr)

    if attr_type:
        attr['type'] = get_xml_type(val)
    attrstring = make_attrstring(attr)
    return '<%s%s></%s>' % (key, attrstring, key)
695180
@Nullable
    public static String nullIfBlank(@Nullable String value) {
        if (isBlank(value)) {
            return null;
        }
        return value;
    }
85004
public Element getElement(NodeList list, String key, String value) {
	int len = list.getLength();
	for (int i = 0; i < len; i++) {
	    Node n = list.item(i);
	    if (n instanceof Element) {
		Element el = (Element) n;
		if (el.getAttribute(key).equalsIgnoreCase(value)) return el;
	    }
	}
	return null;
    }
229002
public static String toXml(Object root) {
		Class clazz = ClassUtil.unwrapCglib(root);
		return toXml(root, clazz, null);
	}
211940
function(result) {
    var oResult = {},
        schema = this.responseSchema;
        
    try {
        // Loop through each data field in each result using the schema
        for(var m = schema.fields.length-1; m >= 0 ; m--) {
            var field = schema.fields[m];
            var key = (lang.isValue(field.key)) ? field.key : field;
            var data = null;

            if(this.useXPath) {
                data = YAHOO.util.DataSource._getLocationValue(field, result);
            }
            else {
                // Values may be held in an attribute...
                var xmlAttr = result.attributes.getNamedItem(key);
                if(xmlAttr) {
                    data = xmlAttr.value;
                }
                // ...or in a node
                else {
                    var xmlNode = result.getElementsByTagName(key);
                    if(xmlNode && xmlNode.item(0)) {
                        var item = xmlNode.item(0);
                        // For IE, then DOM...
                        data = (item) ? ((item.text) ? item.text : (item.textContent) ? item.textContent : null) : null;
                        // ...then fallback, but check for multiple child nodes
                        if(!data) {
                            var datapieces = [];
                            for(var j=0, len=item.childNodes.length; j<len; j++) {
                                if(item.childNodes[j].nodeValue) {
                                    datapieces[datapieces.length] = item.childNodes[j].nodeValue;
                                }
                            }
                            if(datapieces.length > 0) {
                                data = datapieces.join("");
                            }
                        }
                    }
                }
            }
            
            
            // Safety net
            if(data === null) {
                   data = "";
            }
            // Backward compatibility
            if(!field.parser && field.converter) {
                field.parser = field.converter;
                YAHOO.log("The field property converter has been deprecated" +
                        " in favor of parser", "warn", this.toString());
            }
            var parser = (typeof field.parser === 'function') ?
                field.parser :
                DS.Parser[field.parser+''];
            if(parser) {
                data = parser.call(this, data);
            }
            // Safety measure
            if(data === undefined) {
                data = null;
            }
            oResult[key] = data;
        }
    }
    catch(e) {
        YAHOO.log("Error while parsing XML result: " + e.message);
    }

    return oResult;
}
1152715
private static function array_to_xml($data = array(), &$xml_data) {
	foreach($data as $key => $value) {

	    if(is_array($value) or (is_object($value))) {
		if(!is_numeric($key)){
		    $subnode = $xml_data->addChild("$key");
		    self::array_to_xml($value, $subnode);
		}
		else{
		    $subnode = $xml_data->addChild("element");
		    self::array_to_xml($value, $subnode);
		}
	    }
	    else {
		if (is_bool($value)) {$value = $value ? "true" : "false";}
		$xml_data->addChild("$key","$value");
	    }
	}
    }
426971
String convertToString(Object value) {
        if (value == null) {
            return null;
        } else if (value instanceof String) {
            return (String) value;
        } else if (value instanceof List) {
            List<?> list = ((List<?>) value);
            if (list.size() == 0) {
                return EvaluationContext.EMPTY_STRING;
            } else if (list.size() == 1) {
                String strValue = String.valueOf(list.get(0));
                return escapeValue(strValue);
            } else {
                StringBuilder builder = new StringBuilder();
                Iterator<?> iterator = list.iterator();
                while (iterator.hasNext()) {
                    String strValue = String.valueOf(iterator.next());
                    strValue = escapeValue(strValue);
                    builder.append(strValue);
                    if (iterator.hasNext()) {
                        builder.append(", ");
                    }
                }
                return builder.toString();
            }
        } else if (value instanceof String[]) {
            String[] array = (String[]) value;
            if (array.length == 0) {
                return EvaluationContext.EMPTY_STRING;
            } else if (array.length == 1) {
                return escapeValue(array[0]);
            } else {
                StringBuilder builder = new StringBuilder();
                for (int i = 0; i < array.length; i++) {
                    String strValue = escapeValue(array[i]);
                    builder.append(strValue);
                    if (i + 1 < array.length) {
                        builder.append(", ");
                    }
                }
                return builder.toString();
            }
        } else if (value.getClass().isArray()) {
            int size = Array.getLength(value);
            if (size == 0) {
                return EvaluationContext.EMPTY_STRING;
            } else if (size == 1) {
                String strValue = String.valueOf(Array.get(value, 0));
                return escapeValue(strValue);
            } else {
                StringBuilder builder = new StringBuilder();
                for (int i = 0; i < size; i++) {
                    String strValue = String.valueOf(Array.get(value, i));
                    strValue = escapeValue(strValue);
                    builder.append(strValue);
                    if (i + 1 < size) {
                        builder.append(", ");
                    }
                }
                return builder.toString();
            }
        } else {
            return value.toString();
        }
    }
420686
private Integer getNullOnValue(Integer value, int nullValue)
   {
      return (NumberHelper.getInt(value) == nullValue ? null : value);
   }
17149
function (xmlNode, nodeName) {

            var childs = xmlNode.childNodes;

            for (var i = 0; i < childs.length; ++i) {

                var item = childs.item(i);

                if (item.nodeType !== 1) {
                    continue;
                }

                if ((item.nodeName && !nodeName) || (nodeName && nodeName === item.nodeName)) {
                    return item;
                }
            }

            return null;
        }
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;
  }
46688
private SoyValue visitNullSafeNode(ExprNode node) {
    SoyValue value = visitNullSafeNodeRecurse(node);
    // Transform null sentinel into a normal null value.
    if (value == NullSafetySentinel.INSTANCE) {
      return NullData.INSTANCE;
    }
    return value;
  }
1314871
function (xmlNode) {
            if (!xmlNode) {
                return null;
            }

            var text = xmlNode.textContent;
            text = text.replace(/\n/gi, " ");
            text = text.replace(/\s+/gi, " ");
            text = text.trim();

            if (text.length === 0) {
                return null;
            }

            return text.split(" ");
        }
534175
function( elem, name, isXML ) {
			var ret;
			return isXML ?
				undefined :
				(ret = elem.getAttributeNode( name )) && ret.value !== "" ?
					ret.value :
					null;
		}
326258
function textXml(data) {
                var xml = undefined,
                    tmp = undefined;
                if (!data || typeof data !== "string") {
                    return null;
                }

                // Support: IE9
                try {
                    tmp = new DOMParser();
                    xml = tmp.parseFromString(data, "text/xml");
                } catch (e) {
                    xml = undefined;
                }

                if (!xml || xml.getElementsByTagName("parsererror").length) {
                    throwError("Invalid XML: " + data);
                }
                return xml;
            }
600109
private String appendXmlStartTag(String value)  {
        StringBuilder sb = new StringBuilder();
        sb.append("<").append(value).append(">");

        return sb.toString();
    }
452383
def to_xml(value, options = {})
      if value.is_a?(Exchanger::Element)
        value.tag_name = tag_name
        value.to_xml(options)
      else
        doc = Nokogiri::XML::Document.new
        root = doc.create_element(tag_name)
        case value
        when Array
          value.each do |sub_value|
            root << sub_field.to_xml(sub_value, options)
          end
        when Boolean
          root << doc.create_text_node(value == true)
        when Time
          root << doc.create_text_node(value.xmlschema)
        else # String, Integer, etc
          root << doc.create_text_node(value.to_s)
        end
        root
      end
    end
1304117
private Object value(Object obj, Element node) throws Exception {
		Object value = null;

		// Get the type
		String type = getAttribute(node, "type");

		// Try a ref lookup
		String ref = getAttribute(node, "ref");
		if (ref != null) {
			value = _idMap.get(ref);
		} else {
			// handle trivial case
			if (getChildren(node).length == 0
					&& (getValue(node) == null || getValue(node).length() == 0)) {
				if ("String".equals(type)) {
					return "";
				}
				return null;
			}

			// Trim values
			int first = 0;
			int last = /*
						 * getChildren(node).length - 1; int valLast =
						 */getValue(node).length() - 1;

			// Handle default trim type
			if (type == null || !"String".equals(type)) {
				// Skip leading white
				Object item = null;
				while (first <= last) {
					item = /*
							 * getChildren(node)[first]; val =
							 */getValue(node);
					if (!(item instanceof String)) {
						break;
					}
					item = ((String) item).trim();
					if (((String) item).length() > 0) {
						break;
					}
					first++;
				}

				// Skip trailing white
				while (first < last) {
					item = getValue(node);
					if (!(item instanceof String)) {
						break;
					}
					item = ((String) item).trim();
					if (((String) item).length() > 0) {
						break;
					}
					last--;
				}

				// All white, so return null
				if (first > last) {
					// first check if there are maybe is another child left
					if (getChildren(node).length == 0) {
						return null;
					} else {
						value = itemValue(obj, getChildren(node)[0]);
					}
				} else {
					value = item;
				}
			} else  if (first == last) {
	            // Single Item value
	            value = itemValue(obj,getChildren(node)[0]);
		    } else {
	            value = getValue(node);
	        }
		}
		
		

		// Untyped or unknown
		if (value == null) {
			if ("String".equals(type)) {
				return "";
			}
			return null;
		}

		// Try to type the object
		if (type == null) {
			if (value != null && value instanceof String) {
				return ((String) value).trim();
			}
			return value;
		}

		if ("String".equals(type) || "java.lang.String".equals(type)) {
			return value.toString();
		}

		Class<?> pClass = TypeUtil.fromName(type);
		if (pClass != null) {
			return TypeUtil.valueOf(pClass, value.toString());
		}

		if ("URL".equals(type) || "java.net.URL".equals(type)) {
			if (value instanceof URL) {
				return value;
			}
			try {
				return new URL(value.toString());
			} catch (MalformedURLException e) {
				throw new InvocationTargetException(e);
			}
		}

		if ("InetAddress".equals(type) || "java.net.InetAddress".equals(type)) {
			if (value instanceof InetAddress) {
				return value;
			}
			try {
				return InetAddress.getByName(value.toString());
			} catch (UnknownHostException e) {
				throw new InvocationTargetException(e);
			}
		}

		throw new IllegalStateException("Unknown type " + type);
	}