List of usage examples for org.w3c.dom Node getNextSibling
public Node getNextSibling();
From source file:org.jasig.portal.layout.simple.RDBMUserLayoutStore.java
/** * Dump a document tree structure on stdout * @param node//from w w w .j a v a 2 s. co m * @param indent */ public static final void dumpDoc(Node node, String indent) { if (node == null) { return; } if (node instanceof Element) { System.err.print(indent + "element: tag=" + ((Element) node).getTagName() + " "); } else if (node instanceof Document) { System.err.print("document:"); } else { System.err.print(indent + "node:"); } System.err.println("name=" + node.getNodeName() + " value=" + node.getNodeValue()); NamedNodeMap nm = node.getAttributes(); if (nm != null) { for (int i = 0; i < nm.getLength(); i++) { System.err .println(indent + " " + nm.item(i).getNodeName() + ": '" + nm.item(i).getNodeValue() + "'"); } System.err.println(indent + "--"); } if (node.hasChildNodes()) { dumpDoc(node.getFirstChild(), indent + " "); } dumpDoc(node.getNextSibling(), indent); }
From source file:org.jasig.portal.layout.simple.SimpleLayout.java
@Override public String getNextSiblingId(String nodeId) throws PortalException { String nextSiblingId = null;/*ww w . j a v a 2s . c o m*/ Element element = layout.getElementById(nodeId); if (element != null) { Node sibling = element.getNextSibling(); // Find the next element node while (sibling != null && sibling.getNodeType() != Node.ELEMENT_NODE) { sibling = sibling.getNextSibling(); } if (sibling != null) { Element e = (Element) sibling; nextSiblingId = e.getAttribute("ID"); } } return nextSiblingId; }
From source file:org.kuali.coeus.propdev.impl.budget.subaward.PropDevPropDevBudgetSubAwardServiceImpl.java
private void setValue(Node node, String value) { Node child = null; for (child = node.getFirstChild(); child != null; child = child.getNextSibling()) { if (child.getNodeType() == Node.TEXT_NODE) { child.setNodeValue(value);// ww w . j a v a 2 s . co m break; } } }
From source file:org.kuali.coeus.propdev.impl.budget.subaward.PropDevPropDevBudgetSubAwardServiceImpl.java
private static String getValue(Node node) { String textValue = ""; Node child = null; if (node != null) for (child = node.getFirstChild(); child != null; child = child.getNextSibling()) { if (child.getNodeType() == Node.TEXT_NODE) { textValue = child.getNodeValue(); break; }/* ww w . j av a 2 s . co m*/ } return textValue.trim(); }
From source file:org.kuali.rice.krad.demo.uif.library.fields.DemoFieldsActionAft.java
protected void testActionFieldImages() throws Exception { WebElement exampleDiv = navigateToExample("Demo-ActionField-Example5"); List<WebElement> fields = exampleDiv.findElements(By.cssSelector("a.uif-actionLink")); assertEquals(2, fields.size());// ww w. j a v a 2 s . co m WebElement leftField = fields.get(0); WebElement rightField = fields.get(1); String leftFieldId = leftField.getAttribute("id"); String rightFieldId = rightField.getAttribute("id"); DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); XPath xPathFactory = XPathFactory.newInstance().newXPath(); Document document = builder.parse(IOUtils.toInputStream(driver.getPageSource())); Node leftFieldImg = (Node) xPathFactory.evaluate("//a[@id='" + leftFieldId + "']/img", document, XPathConstants.NODE); Node leftFieldImgNextSibling = leftFieldImg.getNextSibling(); if (!leftFieldImgNextSibling.getTextContent().contains("Action Link with left image")) { fail("Image is not on the left of the link"); } Node rightFieldText = (Node) xPathFactory.evaluate( "//a[@id='" + rightFieldId + "']/text()[contains(., 'Action Link with right image')]", document, XPathConstants.NODE); Node rightFieldTextNextSibling = rightFieldText.getNextSibling(); if (!rightFieldTextNextSibling.getNodeName().equals("img")) { fail("Image is not on the right of the link"); } }
From source file:org.kuali.rice.krad.demo.uif.library.fields.DemoFieldsActionAft.java
protected void testActionFieldButtons() throws Exception { WebElement exampleDiv = navigateToExample("Demo-ActionField-Example6"); List<WebElement> fields = exampleDiv.findElements(By.cssSelector("button.btn-primary")); assertEquals(7, fields.size());//from w w w .ja v a 2 s.c om String buttonFieldId = fields.get(0).getAttribute("id"); String imageBottomFieldId = fields.get(1).getAttribute("id"); String imageTopFieldId = fields.get(2).getAttribute("id"); String imageLeftFieldId = fields.get(3).getAttribute("id"); String imageRightFieldId = fields.get(4).getAttribute("id"); DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); XPath xPathFactory = XPathFactory.newInstance().newXPath(); Document document = builder.parse(IOUtils.toInputStream(driver.getPageSource())); assertIsVisible("#" + buttonFieldId); waitAndClickButtonByText(fields.get(0).getText()); assertTrue(driver.switchTo().alert().getText().contains("You clicked a button")); alertAccept(); assertElementPresent("#" + imageBottomFieldId + " span.topBottomSpan img[src*='searchicon.png']"); Node topFieldText = (Node) xPathFactory.evaluate( "//button[@id='" + imageBottomFieldId + "']/text()[contains(., 'Image BOTTOM')]", document, XPathConstants.NODE); Node topFieldTextNextSibling = topFieldText.getNextSibling(); if (!topFieldTextNextSibling.getNodeName().equals("span")) { fail("Image is not on the bottom of the text"); } assertElementPresent("#" + imageTopFieldId + " span.topBottomSpan img[src*='searchicon.png']"); Node bottomFieldText = (Node) xPathFactory.evaluate( "//button[@id='" + imageTopFieldId + "']/text()[contains(., 'Image TOP')]", document, XPathConstants.NODE); Node bottomFieldImgNextSibling = bottomFieldText.getPreviousSibling(); if (!bottomFieldImgNextSibling.getNodeName().contains("span")) { fail("Image is not on the top of the text"); } Node leftFieldImg = (Node) xPathFactory.evaluate("//button[@id='" + imageLeftFieldId + "']/img", document, XPathConstants.NODE); Node leftFieldImgNextSibling = leftFieldImg.getNextSibling(); if (!leftFieldImgNextSibling.getTextContent().contains("Image LEFT")) { fail("Image is not on the left of the text"); } Node rightFieldText = (Node) xPathFactory.evaluate( "//button[@id='" + imageRightFieldId + "']/text()[contains(., 'Image RIGHT')]", document, XPathConstants.NODE); Node rightFieldTextNextSibling = rightFieldText.getNextSibling(); if (!rightFieldTextNextSibling.getNodeName().equals("img")) { fail("Image is not on the right of the text"); } driver.findElement(By .xpath("//button[contains(text(),'Disabled Button') and @disabled]/preceding-sibling::button/img")); driver.findElement(By.xpath("//button/img[contains(@alt,'Image Only button')]")); driver.findElement(By.xpath("//button[contains(text(),'Disabled Button') and @disabled]")); }
From source file:org.kuali.test.utils.Utils.java
/** * * @param node//from w ww. ja va 2 s . c o m * @return */ public static List<Element> getChildElements(Element node) { List<Element> retval = new ArrayList<Element>(); Node child = node.getFirstChild(); while (child != null) { if (child instanceof Element) { retval.add((Element) child); } child = child.getNextSibling(); } return retval; }
From source file:org.kuali.test.utils.Utils.java
/** * * @param node/*from w ww . j av a2 s.co m*/ * @return */ public static Element getNextSiblingElement(Node node) { Element retval = null; Node sibling = node.getNextSibling(); while ((sibling != null) && !isElement(sibling)) { sibling = sibling.getNextSibling(); } if (isElement(sibling)) { retval = (Element) sibling; } return retval; }
From source file:org.loklak.api.iot.NetmonPushServlet.java
private static JSONObject convertDOMNodeToMap(Node node) { Node directChild = node.getFirstChild(); if (directChild == null) { return null; }//from w ww .j av a 2 s .c o m JSONObject result = new JSONObject(true); while (directChild != null) { if (directChild.getChildNodes().getLength() == 1 && directChild.getChildNodes().item(0).getNodeType() == Node.TEXT_NODE) { result.put(directChild.getNodeName(), directChild.getChildNodes().item(0).getTextContent()); } else { result.put(directChild.getNodeName(), convertDOMNodeToMap(directChild)); } directChild = directChild.getNextSibling(); } return result; }
From source file:org.metaeffekt.dcc.commons.ant.MergeXmlTaskTest.java
private Object getNextSibling(Node node) { Node currentNode = node; while (currentNode.getNextSibling() != null && currentNode.getNextSibling().getNodeType() != Node.ELEMENT_NODE) { currentNode = currentNode.getNextSibling(); }/*from w w w . ja va2s .c o m*/ return currentNode.getNextSibling(); }