*
     * @return <code>XPathFactory</code> as determined by <code>keyName</code> value or <code>null</code> if there was an error.
     *
     * @throws IOException If IO error reading from <code>in</code>.
     */
    private XPathFactory loadFromService(
            String objectModel,
            String inputName,
            InputStream in)
            throws IOException {

            XPathFactory xPathFactory = null;
            final Class[] stringClassArray = {"".getClass()};
            final Object[] objectModelObjectArray = {objectModel};
            final String isObjectModelSupportedMethod = "isObjectModelSupported";

            debugPrintln("Reading " + inputName);

            // read from InputStream until a match is found
            BufferedReader configFile = new BufferedReader(new InputStreamReader(in));
            String line = null;
            while ((line = configFile.readLine()) != null) {
                    // '#' is comment char
                    int comment = line.indexOf("#");
                    switch (comment) {
                            case -1: break; // no comment
                            case 0: line = ""; break; // entire line is a comment
                            default: line = line.substring(0, comment); break; // trim comment
                    }

                    // trim whitespace
                    line = line.trim();

                    // any content left on line?
                    if (line.length() == 0) {
                            continue;
                    }

                    // line content is now the name of the class
                    Class clazz = createClass(line);
                    if (clazz == null) {
                            continue;
                    }

                    // create an instance of the Class
                    try {
                            xPathFactory = (XPathFactory) clazz.newInstance();
                    } catch (ClassCastException classCastExcpetion) {
                            xPathFactory = null;
                            continue;
                    } catch (InstantiationException instantiationException) {
                            xPathFactory = null;
                            continue;
                    } catch (IllegalAccessException illegalAccessException) {
                            xPathFactory = null;
                            continue;
                    }

                    // does this Class support desired object model?
                    try {
                            Method isObjectModelSupported = clazz.getMethod(isObjectModelSupportedMethod, stringClassArray);
                            Boolean supported = (Boolean) isObjectModelSupported.invoke(xPathFactory, objectModelObjectArray);
                            if (supported.booleanValue()) {
                                    break;
                            }

                    } catch (NoSuchMethodException noSuchMethodException) {

                    } catch (IllegalAccessException illegalAccessException) {

                    } catch (InvocationTargetException invocationTargetException) {

                    }
                    xPathFactory = null;
            }

            // clean up
            configFile.close();

            // return new instance of XPathFactory or null
            return xPathFactory;
    }