Package org.jdom.filter

Examples of org.jdom.filter.ElementFilter


            System.out.println(c);
        }

        System.out.println();
        System.out.println("Only elements:");
        itr = doc.getDescendants(new ElementFilter());
        while (itr.hasNext()) {
            Content c = (Content) itr.next();
            System.out.println(c);
        }

        System.out.println();
        System.out.println("Everything that's not an element:");
        itr = doc.getDescendants(new ElementFilter().negate());
        while (itr.hasNext()) {
            Content c = (Content) itr.next();
            System.out.println(c);
        }

        System.out.println();
        System.out.println("Only elements with localname of servlet:");
        itr = doc.getDescendants(new ElementFilter("servlet"));
        while (itr.hasNext()) {
            Content c = (Content) itr.next();
            System.out.println(c);
        }

        System.out.println();
        System.out.println(
             "Only elements with localname of servlet-name or servlet-class:");
        itr = doc.getDescendants(new ElementFilter("servlet-name")
                                 .or(new ElementFilter("servlet-class")));
        while (itr.hasNext()) {
            Content c = (Content) itr.next();
            System.out.println(c);
        }

        System.out.println();
        System.out.println("Remove elements with localname of servlet:");
        itr = doc.getDescendants(new ElementFilter("servlet"));
        while (itr.hasNext()) {
            itr.next();
            itr.remove();
        }
View Full Code Here


                    DOIIdentifierException.BAD_ANSWER);
        }
       
        String handle = null;
       
        Iterator<Element> it = doc.getDescendants(new ElementFilter("alternateIdentifier"));
        while (handle == null && it.hasNext())
        {
            Element alternateIdentifier = it.next();
            try
            {
View Full Code Here

    Document doc = builder.build(nexusFile)
    assertTrue("Empty doc.", doc != null);
    Element root = doc.getRootElement();
    Namespace ns = Namespace.getNamespace("");
    XPath xPath = XPath.newInstance("entity");
    Filter eleFilter = new ElementFilter("entity", null);
   
    // 6. verify search:
    //List<Element> allEles = xPath.selectNodes(doc);
    Iterator<Element> iter = doc.getDescendants(eleFilter);
    Element ele = iter.next();
View Full Code Here

            {
                rootElement.setAttribute( "schemaLocation", "http://maven.apache.org/POM/4.0.0 "
                    + ( isPom ? POM_XSD_URL : SETTINGS_XSD_URL ), xsiNamespace );
            }

            ElementFilter elementFilter = new ElementFilter( Namespace.getNamespace( "" ) );
            for ( Iterator<?> i = rootElement.getDescendants( elementFilter ); i.hasNext(); )
            {
                Element e = (Element) i.next();
                e.setNamespace( pomNamespace );
            }
View Full Code Here

            {
                rootElement.setAttribute( "schemaLocation", "http://maven.apache.org/POM/4.0.0 "
                    + ( isPom ? POM_XSD_URL : SETTINGS_XSD_URL ), xsiNamespace );
            }

            ElementFilter elementFilter = new ElementFilter( Namespace.getNamespace( "" ) );
            for ( Iterator i = rootElement.getDescendants( elementFilter ); i.hasNext(); )
            {
                Element e = (Element) i.next();
                e.setNamespace( pomNamespace );
            }
View Full Code Here

                if (in != null) {
                    SAXBuilder builder = new SAXBuilder();
                    Document document = builder.build(in);
                    @SuppressWarnings("unchecked")
                    Iterator<Element> it = document
                            .getDescendants(new ElementFilter("uri"));
                    while (it.hasNext()) {
                        Element next = it.next();
                        String uri = next.getAttributeValue("uri");
                        String name = next.getAttributeValue("name");
                        // URI is now something like platform:/fragment/org.milyn.edi.unedifact.d99a-mapping/path/path/file.xsd
View Full Code Here

TOP

Related Classes of org.jdom.filter.ElementFilter

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.