Package org.jdom.xpath

Examples of org.jdom.xpath.XPath


    }

    @SuppressWarnings("unchecked")
    private List<Element> getMatches(Object doc, String xpath) {
        try {
            XPath path = XPath.newInstance(xpath);
            return path.selectNodes(doc);
        } catch (JDOMException e) {
            throw new DatabindingException("Error evaluating xpath " + xpath, e);
        }
    }
View Full Code Here


        throws JDOMException,
               IOException
    {
        Document doc = new SAXBuilder().build( xmlStream );
       
        XPath xpath = XPath.newInstance("/pagefilters/filter");
   
        List nodes = xpath.selectNodes( doc );
       
        for( Iterator i = nodes.iterator(); i.hasNext(); )
        {
            Element f = (Element) i.next();
           
View Full Code Here

    {
        StringBuffer sb = new StringBuffer();
       
        try
        {
            XPath xp = XPath.newInstance( ALL_TEXT_NODES );
       
            List nodes = xp.selectNodes(m_document.getDocument());
           
            for( Iterator i = nodes.iterator(); i.hasNext(); )
            {
                Object el = i.next();
               
View Full Code Here

        try
        {
            Document doc = new SAXBuilder().build( req.getInputStream() );
                   
            XPath xpath = XPath.newInstance("/D:propfind/*");
            xpath.addNamespace( "D", "DAV:" );
       
            Element firstnode = (Element)xpath.selectSingleNode( doc );

            Element davresponse = null;

            System.out.println("Request="+dc.getPath()+" depth="+dc.getDepth());

            if( firstnode == null || firstnode.getName().equals("allprop") )
            {
                davresponse = getAllProps( dc );
            }
            else if( firstnode.getName().equals("propname") )
            {
                davresponse = getPropertyNames( dc );
            }
            else if( firstnode.getName().equals("prop") )
            {
                XPath ndxp = XPath.newInstance("/D:propfind/D:prop/*");
                ndxp.addNamespace( "D", "DAV:" );
               
                List nodes = ndxp.selectNodes( doc );
                davresponse = getProperties( dc, nodes );
            }
           
            sendMultiResponse( res, davresponse );
View Full Code Here

     * @throws JDOMException if elements cannot be parsed correctly
     */
    public boolean isConstrained( String url, Role role ) throws JDOMException
    {
        Element root = m_webxml.getRootElement();
        XPath xpath;
        String selector;

        // Get all constraints that have our URL pattern
        // (Note the crazy j: prefix to denote the 2.4 j2ee schema)
        selector = "//j:web-app/j:security-constraint[j:web-resource-collection/j:url-pattern=\"" + url + "\"]";
        xpath = XPath.newInstance( selector );
        xpath.addNamespace( "j", J2EE_SCHEMA_24_NAMESPACE );
        List<?> constraints = xpath.selectNodes( root );

        // Get all constraints that match our Role pattern
        selector = "//j:web-app/j:security-constraint[j:auth-constraint/j:role-name=\"" + role.getName() + "\"]";
        xpath = XPath.newInstance( selector );
        xpath.addNamespace( "j", J2EE_SCHEMA_24_NAMESPACE );
        List<?> roles = xpath.selectNodes( root );

        // If we can't find either one, we must not be constrained
        if ( constraints.size() == 0 )
        {
            return false;
View Full Code Here

        Set<Role> roles = new HashSet<Role>();
        Element root = webxml.getRootElement();

        // Get roles referred to by constraints
        String selector = "//j:web-app/j:security-constraint/j:auth-constraint/j:role-name";
        XPath xpath = XPath.newInstance( selector );
        xpath.addNamespace( "j", J2EE_SCHEMA_24_NAMESPACE );
        List<?> nodes = xpath.selectNodes( root );
        for( Iterator<?> it = nodes.iterator(); it.hasNext(); )
        {
            String role = ( (Element) it.next() ).getTextTrim();
            roles.add( new Role( role ) );
        }

        // Get all defined roles
        selector = "//j:web-app/j:security-role/j:role-name";
        xpath = XPath.newInstance( selector );
        xpath.addNamespace( "j", J2EE_SCHEMA_24_NAMESPACE );
        nodes = xpath.selectNodes( root );
        for( Iterator<?> it = nodes.iterator(); it.hasNext(); )
        {
            String role = ( (Element) it.next() ).getTextTrim();
            roles.add( new Role( role ) );
        }
View Full Code Here

        // now check extension of archivenames to be jar
        SAXBuilder builder = new SAXBuilder( false );

        Document doc = builder.build( new File( basedir, ".settings/org.eclipse.wst.common.component" ) );

        XPath archiveNames = XPath.newInstance( "//dependent-module/@archiveName" );

        assertEquals( "Must be 2 modules", 2, archiveNames.selectNodes( doc ).size() );
        for ( Iterator it = archiveNames.selectNodes( doc ).iterator(); it.hasNext(); )
        {
            Attribute attribute = (Attribute) it.next();

            String archiveName = attribute.getValue();
            String extension = archiveName.substring( archiveName.lastIndexOf( "." ) + 1 ).toLowerCase();
View Full Code Here

        SAXBuilder builder = new SAXBuilder( false );

        Document doc = builder.build( new File( basedir, ".classpath" ) );

        XPath resourcePath = XPath.newInstance( "//classpathentry[@path='src/main/resources']" );

        assertTrue( "resources classpath entry not found.", resourcePath.selectSingleNode( doc ) != null );

        XPath testResourcePath = XPath.newInstance( "//classpathentry[@path='src/test/resources']" );

        assertTrue( "test resources (minus custom output dir) classpath entry not found.",
                    testResourcePath.selectSingleNode( doc ) != null );

        XPath stdOutputPath = XPath.newInstance( "//classpathentry[@kind='output' && @path='target/classes']" );

        assertTrue( "standard output classpath entry not found.", stdOutputPath.selectSingleNode( doc ) != null );

    }
View Full Code Here

        SAXBuilder builder = new SAXBuilder( false );

        Document doc = builder.build( new File( basedir, ".classpath" ) );

        XPath javadocUrls = XPath.newInstance( "//attribute/@value" );
        for ( Iterator it = javadocUrls.selectNodes( doc ).iterator(); it.hasNext(); )
        {
            Attribute attribute = (Attribute) it.next();
            URL jarUrl = new URL( attribute.getValue() );
            URL fileUrl = ( (JarURLConnection) jarUrl.openConnection() ).getJarFileURL();
            String host = fileUrl.getHost();
View Full Code Here

        try {
            SAXBuilder saxBuilder = new SAXBuilder();
            Document document = saxBuilder.build(content);
            for (Iterator i = instructions.iterator(); i.hasNext();) {
                Instruction instruction = (Instruction) i.next();
                XPath xPath = instruction.getxPath();
                List nodeList = xPath.selectNodes(document);
                Object propertyValue = filter(nodeList, instruction);
                if (propertyValue != null) {
                    properties.put(instruction.getPropertyName(), propertyValue);
                }
            }
View Full Code Here

TOP

Related Classes of org.jdom.xpath.XPath

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.