Code example for XPath

Methods: compile

0
    } 
 
    private void checkP2ContentXml(File p2Content) throws Exception {
        assertTrue(p2Content.isFile());
        Document p2ContentDOM = docBuilder.parse(p2Content);
        XPathExpression sourceBundleUnitExpression = xpath.compile("/units/unit[@id = 'helloworld.source']");
        Element sourceBundleUnitNode = (Element) sourceBundleUnitExpression.evaluate(p2ContentDOM.getDocumentElement(),
                XPathConstants.NODE);
        assertNotNull("unit with id 'helloworld.source' not found", sourceBundleUnitNode);
        assertHasMavenClassifierProperty(sourceBundleUnitNode);
    } 
 
    private void assertHasMavenClassifierProperty(Element node) throws XPathExpressionException {
        XPathExpression classifierNodeExpression = xpath.compile("properties/property[@name = 'maven-classifier']");
        Element classifierNode = (Element) classifierNodeExpression.evaluate(node, XPathConstants.NODE);
        assertNotNull("property node with name 'maven-classifier' not found", classifierNode);
        assertEquals("sources", classifierNode.getAttribute("value"));
    } 
 
    private void checkP2ArtifactsXml(File p2Artifacts) throws SAXException, IOException, ParserConfigurationException,
            XPathExpressionException {