class XmlUtils {

    public static String createValidId(String value) {
        if (isEmpty(value)) {
            return "_";
        }

        StringBuilder resultId = new StringBuilder();

        for (int i = 0; i < value.length(); i++) {
            if (isNcNameCharacter(value.charAt(i))) {
                resultId.append(value.charAt(i));
            }
        }

        String result = resultId.toString();
        if (isEmpty(result)) {
            return "_";
        }

        if (isNcNameStartCharacter(result.charAt(0))) {
            return result;
        }

        return "_" + result;
    }

    private  XmlUtils();

}