Package nu.xom

Examples of nu.xom.XPathContext.addNamespace()


        }   
       
        Nodes doc2Queries = root.query("child::query[starts-with(@id, 'A')]");
       
        XPathContext context = new XPathContext();
        context.addNamespace("svg", "http://www.w3.org/2000/svg");
        context.addNamespace("xlink", "http://www.w3.org/1999/xlink");
       
        for (int i = 0; i < doc2Queries.size(); i++) {
            Element query = (Element) doc2Queries.get(i);
            String xpath = query.getFirstChildElement("syntax").getValue();
View Full Code Here


       
        Nodes doc2Queries = root.query("child::query[starts-with(@id, 'A')]");
       
        XPathContext context = new XPathContext();
        context.addNamespace("svg", "http://www.w3.org/2000/svg");
        context.addNamespace("xlink", "http://www.w3.org/1999/xlink");
       
        for (int i = 0; i < doc2Queries.size(); i++) {
            Element query = (Element) doc2Queries.get(i);
            String xpath = query.getFirstChildElement("syntax").getValue();
            String id = query.getAttributeValue("id");
View Full Code Here

   
    public void testCantRebindXMLPrefix() {
       
        XPathContext context = new XPathContext();
        try {
            context.addNamespace("xml", "http://www.example.org");
            fail("Rebound xml prefix");
        }
        catch (NamespaceConflictException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

   
    public void testNamespaceQueryWithNullPrefix() {
       
        try {
            XPathContext context = new XPathContext("pre", "http://www.example.org");
            context.addNamespace(null, "http://www.w3.org");
            fail("Allowed null prefix");
        }
        catch (NullPointerException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

   
    public void testNamespaceQueryWithEmptyPrefix() {
       
        try {
            XPathContext context = new XPathContext("pre", "http://www.example.org");
            context.addNamespace("", "http://www.w3.org");
        }
        catch (NamespaceConflictException success) {
            assertTrue(success.getMessage().length() > 1);
        }
       
View Full Code Here

       
        XPathContext context = new XPathContext("pre", "http://www.example.com");
        Nodes result = parent.query("child::pre:child", context);
        assertEquals(0, result.size());
       
        context.addNamespace("pre", "http://www.example.org");
        result = parent.query("child::pre:child", context);
        assertEquals(1, result.size());
        assertEquals(child, result.get(0));  
       
    }
View Full Code Here

        Attribute att = new Attribute("c:dog", "http://www.cafeconleche.org/", "test");
        parent.appendChild(child);
        child.addAttribute(att);
       
        XPathContext context = new XPathContext("pre", "http://www.example.org");
        context.addNamespace("c", "http://www.cafeconleche.org/");
        Nodes result = parent.query("child::pre:child", context);
        assertEquals(1, result.size());
        assertEquals(child, result.get(0));
       
        result = child.query("@c:*", context);
View Full Code Here

        XPathContext context = new XPathContext();
        for (int i = 0; i < contextElement.getNamespaceDeclarationCount(); i++) {
            String prefix = contextElement.getNamespacePrefix(i);
            if (! "".equals(prefix)) {
                context.addNamespace(prefix, contextElement.getNamespaceURI(prefix));
            }
        }
        return context;
    }
View Full Code Here

    System.out.println("Fetching " + url);
    Document doc = new Builder().build(url);
    System.out.println("Fetched!");
    //new Serializer(System.out).write(doc);
    XPathContext xpc = new XPathContext();
    xpc.addNamespace("oai", "http://www.openarchives.org/OAI/2.0/");
    xpc.addNamespace("art", "http://dtd.nlm.nih.gov/2.0/xsd/archivearticle");
   
    while(doc != null) {
      Nodes paperNodes = doc.query("/oai:OAI-PMH/oai:ListRecords/oai:record/oai:metadata/art:article", xpc);
      System.out.println("Found " + paperNodes.size() + " papers");
View Full Code Here

    Document doc = new Builder().build(url);
    System.out.println("Fetched!");
    //new Serializer(System.out).write(doc);
    XPathContext xpc = new XPathContext();
    xpc.addNamespace("oai", "http://www.openarchives.org/OAI/2.0/");
    xpc.addNamespace("art", "http://dtd.nlm.nih.gov/2.0/xsd/archivearticle");
   
    while(doc != null) {
      Nodes paperNodes = doc.query("/oai:OAI-PMH/oai:ListRecords/oai:record/oai:metadata/art:article", xpc);
      System.out.println("Found " + paperNodes.size() + " papers");
      for(int i=0;i<paperNodes.size();i++) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.