Package org.exoplatform.services.html.path

Examples of org.exoplatform.services.html.path.NodePath


      assertEquals("ASCII", HTMLParser.getCharset());
      System.out.println("\n\n\n == > charset " + HTMLParser.getCharset() + "\n\n");
      assertNotNull(document);

      //Gets the NodePath object locating the path of a TAG in the HTML file.
      NodePath path = NodePathParser.toPath("html.body.h2");

      //Looks for the Node coresponding to the NodePath object of the HTML document.
      //and checks the existing of this TAG.
      HTMLNode node = NodePathUtil.lookFor(document.getRoot(), path);
      assertEquals(node.getName(), Name.H2);
View Full Code Here


   public void testHead() throws Exception
   {
      HTMLDocument document = HTMLParser.createDocument(this.file_, null);
      String pathStr = "html.head";
      NodePath path = NodePathParser.toPath(pathStr);
      HTMLNode node = NodePathUtil.lookFor(document.getRoot(), path);
      assertNotNull(node);
      assertEquals(node.getName(), Name.HEAD);
      assertEquals(node.getName().toString(), "HEAD");
      List<HTMLNode> children = node.getChildrenNode();
View Full Code Here

   public void testBody() throws Exception
   {
      HTMLDocument document = HTMLParser.createDocument(this.file_, null);
      String pathStr = "html.body";
      NodePath path = NodePathParser.toPath(pathStr);
      HTMLNode node = NodePathUtil.lookFor(document.getRoot(), path);
      assertNotNull(node);
      assertEquals(node.getName(), Name.BODY);
      assertEquals(node.getName().toString(), "BODY");
   }
View Full Code Here

      HTMLDocument htmlDocument = HTMLParser.createDocument(this.file_, null);
      assertNotNull(htmlDocument.getDoctype());
      System.out.println("DOCTYPE: " + htmlDocument.getDoctype().getValue().toString());

      //NodePath.
      NodePath tablePath = NodePathParser.toPath("html.body.table[1]");
      assertNotNull(tablePath);
      System.out.println(tablePath.toString());

      //HTMLNode.
      HTMLNode node = NodePathUtil.lookFor(htmlDocument.getRoot(), tablePath);
      assertNotNull(node);
      assertEquals(node.getName(), Name.TABLE);
View Full Code Here

            + "<h2>This is a test exercise for me!</h2>" + "</body>" + "</html>";
      HTMLDocument document = HTMLParser.createDocument(text);
      assertNotNull(document);

      String pathStr = "html.head.title";
      NodePath path = NodePathParser.toPath(pathStr);
      assertNotNull(path);
      assertEquals(path.toString(), "HTML[0].HEAD[0].TITLE[0]");
      System.out.println("PATH: " + path.toString());

      HTMLNode node = NodePathUtil.lookFor(document.getRoot(), path);
      assertNotNull(node);
      assertEquals(node.getName(), Name.TITLE);
View Full Code Here

      List<HTMLNode> children_ = root.getChildrenNode();
      assertEquals(children_.size(), 2);
      assertEquals(children.size(), children_.size());

      //BODY.
      NodePath path_ = NodePathParser.toPath(children.get(1));
      assertNotNull(path_);
      System.out.println("NODEPATH-CLASS: " + path_.getClass().getName());
      System.out.println("PATH OF BODY: " + path_.toString());
      HTMLNode bodyNode = NodePathUtil.lookFor(document.getRoot(), path_);
      assertEquals(bodyNode, children.get(1));

      String bodyPath = "html.body";
      HTMLNode bodyNode1 = NodePathUtil.lookFor(document.getRoot(), NodePathParser.toPath(bodyPath));
      assertNotNull(bodyNode1);
      assertEquals(bodyNode1, bodyNode);

      //Test Node.getChildren() and Node.getChildrenNode() methods.
      List<HTMLNode> bodyChildren = bodyNode.getChildren();
      List<HTMLNode> bodyChildren1 = bodyNode.getChildrenNode();
      assertEquals(bodyChildren.size(), bodyChildren1.size());
      assertEquals(bodyChildren.size(), 2);
      assertEquals(bodyChildren1.size(), 2);

      //TABLE
      String pathStr = "html.body.table[0]";
      NodePath path = NodePathParser.toPath(pathStr);
      assertNotNull(path);
      HTMLNode tableNode = NodePathUtil.lookFor(document.getRoot(), path);
      assertNotNull(tableNode);
      assertEquals(tableNode.getName(), Name.TABLE);
      assertEquals(tableNode.getName().toString(), "TABLE");
View Full Code Here

      String text =
         "<html>" + "<head>" + "</head>" + "<body>" + "<h1>This is a HTML file for testing!</h1>" + "</body>"
            + "</html>";
      HTMLDocument document = HTMLParser.createDocument(text);
      assertNotNull(document);
      NodePath path = NodePathParser.toPath("html.body.h1");
      HTMLNode node = NodePathUtil.lookFor(document.getRoot(), path);
      assertNotNull(node);
      assertEquals(node.getName(), Name.H1);
      assertEquals(node.getName().toString(), "H1");
      System.out.println("NAME: " + node.getName());
View Full Code Here

TOP

Related Classes of org.exoplatform.services.html.path.NodePath

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.