public NugetPackage parse(InputStream stream) throws NuspecParseException {
        try {
            final DocumentBuilder db = XmlUtils.buildSecureDocumentBuilder();
            final Document d = db.parse(stream);

            final XPath xpath = XPathFactory.newInstance().newXPath();
            final NugetPackage nuspec = new NugetPackage();

            if (xpath.evaluate("/package/metadata/id", d, XPathConstants.NODE) == null
                    || xpath.evaluate("/package/metadata/version", d, XPathConstants.NODE) == null
                    || xpath.evaluate("/package/metadata/authors", d, XPathConstants.NODE) == null
                    || xpath.evaluate("/package/metadata/description", d, XPathConstants.NODE) == null) {
                throw new NuspecParseException("Invalid Nuspec format");
            }

            nuspec.setId(xpath.evaluate("/package/metadata/id", d));
            nuspec.setVersion(xpath.evaluate("/package/metadata/version", d));
            nuspec.setAuthors(xpath.evaluate("/package/metadata/authors", d));
            nuspec.setOwners(getOrNull((Node) xpath.evaluate("/package/metadata/owners", d, XPathConstants.NODE)));
            nuspec.setLicenseUrl(getOrNull((Node) xpath.evaluate("/package/metadata/licenseUrl", d, XPathConstants.NODE)));
            nuspec.setTitle(getOrNull((Node) xpath.evaluate("/package/metadata/title", d, XPathConstants.NODE)));
            nuspec.setDescription(xpath.evaluate("/package/metadata/description", d));
            return nuspec;
        } catch (ParserConfigurationException | SAXException | IOException | XPathExpressionException | NuspecParseException e) {
            throw new NuspecParseException("Unable to parse nuspec", e);
        }
    }
@Test
    public void testGoodDocument() throws Exception {
        XPathNuspecParser parser = new XPathNuspecParser();
        //InputStream is = XPathNuspecParserTest.class.getClassLoader().getResourceAsStream("log4net.2.0.3.nuspec");
        InputStream is = BaseTest.getResourceAsStream(this, "log4net.2.0.3.nuspec");
        NugetPackage np = parser.parse(is);
        assertEquals("log4net", np.getId());
        assertEquals("2.0.3", np.getVersion());
        assertEquals("log4net [1.2.13]", np.getTitle());
        assertEquals("Apache Software Foundation", np.getAuthors());
        assertEquals("Apache Software Foundation", np.getOwners());
        assertEquals("http://logging.apache.org/log4net/license.html", np.getLicenseUrl());
    }