Java Code Examples for org.w3c.dom.Element#getNextSibling()

The following examples show how to use org.w3c.dom.Element#getNextSibling() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UpdateSpringBeanFilter.java    From citrus-admin with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public short accept(Element element) {
    if (added == null && (isEqualById(element, elementId))) {
        if (element.getNextSibling() != null) {
            added = element.getParentNode().insertBefore(element.getOwnerDocument().importNode(beanDefinition, true), element.getNextSibling());
        } else {
            added = element.getParentNode().appendChild(element.getOwnerDocument().importNode(beanDefinition, true));
        }

        updatedBeans++;
    }
    
    if (element.equals(added)) {
        return NodeFilter.FILTER_ACCEPT; 
    }
    
    return super.accept(element);
}
 
Example 2
Source File: HTMLProcessorTest.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void testExecute( ) throws Exception
{
	Document doc = getDomTree( );
	HashMap styles = new HashMap( );
	new HTMLProcessor( (ReportDesignHandle) null, null ).execute(
			(Element) doc.getFirstChild( ), styles );
	Element iEle = (Element) doc.getFirstChild( ).getFirstChild( );
	assertEquals( iEle.getTagName( ), "span" ); //$NON-NLS-1$
	assertEquals( "red", getStyle( styles, iEle, "color" ) ); //$NON-NLS-1$ //$NON-NLS-2$

	Element fontEle = (Element) iEle.getNextSibling( );
	assertEquals( fontEle.getTagName( ), "font" );
	assertEquals( "blue", getStyleAttribute( fontEle, "color" ) );
	assertEquals( "4", getStyleAttribute( fontEle, "size" ) );
	assertEquals( "news", getStyleAttribute( fontEle, "face" ) );

	Element uEle = (Element) fontEle.getNextSibling( );
	assertEquals( uEle.getTagName( ), "span" );
	assertEquals( "overline underline", getStyle( styles, uEle,
			"text-decoration" ) );
}
 
Example 3
Source File: ModifiedRequestTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Override
public void modifySecurityHeader(Element securityHeader) {
    if (securityHeader != null) {
        Element signatureElement =
            XMLUtils.findElement(securityHeader, "Signature", WSS4JConstants.SIG_NS);

        Node firstChild = signatureElement.getFirstChild();
        while (!(firstChild instanceof Element) && firstChild != null) {
            firstChild = signatureElement.getNextSibling();
        }
        ((Element)firstChild).setAttributeNS(null, "Id", "xyz");
    }
}
 
Example 4
Source File: XmlHelper.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static Element findNextSiblingElement(Element current) {
    org.w3c.dom.Node ret = current.getNextSibling();
    while (ret != null) {
        if (ret instanceof Element) {
            return (Element) ret;
        }
        ret = ret.getNextSibling();
    }
    return null;
}
 
Example 5
Source File: XmlHelper.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static Element findNextSiblingElement(Element current) {
    org.w3c.dom.Node ret = current.getNextSibling();
    while (ret != null) {
        if (ret instanceof Element) {
            return (Element) ret;
        }
        ret = ret.getNextSibling();
    }
    return null;
}
 
Example 6
Source File: XmlHelper.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static Element findNextSiblingElement(Element current) {
    org.w3c.dom.Node ret = current.getNextSibling();
    while (ret != null) {
        if (ret instanceof Element) {
            return (Element) ret;
        }
        ret = ret.getNextSibling();
    }
    return null;
}
 
Example 7
Source File: DOMInputCapsule.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Element findNextSiblingElement(Element current) {
    Node ret = current.getNextSibling();
    while (ret != null) {
        if (ret instanceof Element) {
            return (Element) ret;
        }
        ret = ret.getNextSibling();
    }
    return null;
}
 
Example 8
Source File: DOMUtils.java    From cxf-fediz with Apache License 2.0 5 votes vote down vote up
public static Element getNextElement(Element el) {
    Node nd = el.getNextSibling();
    while (nd != null) {
        if (nd.getNodeType() == Node.ELEMENT_NODE) {
            return (Element)nd;
        }
        nd = nd.getNextSibling();
    }
    return null;
}
 
Example 9
Source File: DOMUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static Element getNextElement(Element el) {
    Node nd = el.getNextSibling();
    while (nd != null) {
        if (nd.getNodeType() == Node.ELEMENT_NODE) {
            return (Element)nd;
        }
        nd = nd.getNextSibling();
    }
    return null;
}
 
Example 10
Source File: Xml.java    From RADL with Apache License 2.0 5 votes vote down vote up
public static Element nextElement(Element element) {
  Node current = element.getNextSibling();
  while (current != null) {
    if (current.getNodeType() == Node.ELEMENT_NODE) {
      return (Element)current;
    }
    current = current.getNextSibling();
  }
  return null;
}
 
Example 11
Source File: Handler.java    From container with Apache License 2.0 5 votes vote down vote up
private Element fetchInvokerReceive(final Element invokerAssign, final String requestVarName) {

        Node sibling = invokerAssign.getNextSibling();

        while (sibling != null & !sibling.getNodeName().contains("invoke")) {
            sibling = sibling.getNextSibling();
        }

        if (sibling.getNodeType() == Node.ELEMENT_NODE
            & sibling.getAttributes().getNamedItem("inputVariable").getTextContent().equals(requestVarName)) {
            return (Element) sibling.getNextSibling();
        }

        return null;
    }
 
Example 12
Source File: AppEngineXsltTransformTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddRuntimeAtEnd() {
  Document transformed = transform("/xslt/addJava8Runtime.xsl",
      "<appengine-web-app xmlns=\"http://appengine.google.com/ns/1.0\"><threadsafe>true</threadsafe></appengine-web-app>");
  Element runtime = getRuntimeElement(transformed);
  assertEquals("java8", runtime.getTextContent());
  Text previous = (Text) runtime.getPreviousSibling();
  assertTrue(previous.getNodeValue().trim().isEmpty());
  Text next = (Text) runtime.getNextSibling();
  String s = next.getNodeValue();
  assertEquals("\n", s);
}
 
Example 13
Source File: AbstractBindingBuilder.java    From steady with Apache License 2.0 5 votes vote down vote up
private void insertAfter(Element child, Element sib) {
    if (sib.getNextSibling() == null) {
        secHeader.getSecurityHeader().appendChild(child);
    } else {
        secHeader.getSecurityHeader().insertBefore(child, sib.getNextSibling());
    }
}
 
Example 14
Source File: AbstractBindingBuilder.java    From steady with Apache License 2.0 5 votes vote down vote up
private void insertAfter(Element child, Element sib) {
    if (sib.getNextSibling() == null) {
        secHeader.getSecurityHeader().appendChild(child);
    } else {
        secHeader.getSecurityHeader().insertBefore(child, sib.getNextSibling());
    }
}
 
Example 15
Source File: AbstractBindingBuilder.java    From steady with Apache License 2.0 5 votes vote down vote up
private void insertAfter(Element child, Element sib) {
    if (sib.getNextSibling() == null) {
        secHeader.getSecurityHeader().appendChild(child);
    } else {
        secHeader.getSecurityHeader().insertBefore(child, sib.getNextSibling());
    }
}
 
Example 16
Source File: AbstractBindingBuilder.java    From steady with Apache License 2.0 5 votes vote down vote up
private void insertAfter(Element child, Element sib) {
    if (sib.getNextSibling() == null) {
        secHeader.getSecurityHeader().appendChild(child);
    } else {
        secHeader.getSecurityHeader().insertBefore(child, sib.getNextSibling());
    }
}
 
Example 17
Source File: XMLUtil.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public static Element getNextSibling(Element e) {
  Node n = e.getNextSibling();
  while (n != null && n.getNodeType() != Node.ELEMENT_NODE)
    n = n.getNextSibling();
  return (Element) n;
}
 
Example 18
Source File: JavaToProcessorTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Test
public void testPropOrderInException() throws Exception {
    env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/exception_prop_order.wsdl");
    //env.put(ToolConstants.CFG_OUTPUTFILE, "/x1/tmp/exception_prop_order.wsdl");
    env.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.fortest.exception.EchoImpl");
    env.put(ToolConstants.CFG_VERBOSE, ToolConstants.CFG_VERBOSE);
    try {
        processor.setEnvironment(env);
        processor.process();
    } catch (Exception e) {
        e.printStackTrace();
    }
    File wsdlFile = new File(output, "exception_prop_order.wsdl");
    assertTrue(wsdlFile.exists());

    Document doc = StaxUtils.read(wsdlFile);
    Map<String, String> map = new HashMap<>();
    map.put("xsd", "http://www.w3.org/2001/XMLSchema");
    map.put("wsdl", "http://schemas.xmlsoap.org/wsdl/");
    map.put("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
    XPathUtils util = new XPathUtils(map);

    Element summary = (Element)util.getValueNode("//xsd:element[@name='summary']", doc);
    Element from = (Element)util.getValueNode("//xsd:element[@name='from']", doc);
    Element id = (Element)util.getValueNode("//xsd:element[@name='id']", doc);
    assertNotNull(summary);
    assertNotNull(from);
    assertNotNull(id);

    Node nd = summary.getNextSibling();
    while (nd != null) {
        if (nd == from) {
            from = null;
        } else if (nd == id) {
            if (from != null) {
                fail("id before from");
            }
            id = null;
        }
        nd = nd.getNextSibling();
    }
    assertNull(id);
    assertNull(from);
}
 
Example 19
Source File: JavaToProcessorTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Test
public void testPropOrderInException2() throws Exception {
    env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/exception_prop_order2.wsdl");
    //env.put(ToolConstants.CFG_OUTPUTFILE, "/x1/tmp/exception_prop_order.wsdl");
    env.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.fortest.exception.Echo5Impl");
    env.put(ToolConstants.CFG_VERBOSE, ToolConstants.CFG_VERBOSE);
    try {
        processor.setEnvironment(env);
        processor.process();
    } catch (Exception e) {
        e.printStackTrace();
    }
    File wsdlFile = new File(output, "exception_prop_order2.wsdl");
    assertTrue(wsdlFile.exists());

    Document doc = StaxUtils.read(wsdlFile);
    Map<String, String> map = new HashMap<>();
    map.put("xsd", "http://www.w3.org/2001/XMLSchema");
    map.put("wsdl", "http://schemas.xmlsoap.org/wsdl/");
    map.put("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
    XPathUtils util = new XPathUtils(map);

    Element summary = (Element)util.getValueNode("//xsd:element[@name='summary']", doc);
    Element from = (Element)util.getValueNode("//xsd:element[@name='from']", doc);
    Element id = (Element)util.getValueNode("//xsd:element[@name='id']", doc);
    assertNotNull(summary);
    assertNotNull(from);
    assertNotNull(id);

    Node nd = summary.getNextSibling();
    while (nd != null) {
        if (nd == from) {
            from = null;
        } else if (nd == id) {
            if (from != null) {
                fail("id before from");
            }
            id = null;
        }
        nd = nd.getNextSibling();
    }
    assertNull(id);
    assertNull(from);
}
 
Example 20
Source File: JavaToProcessorTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Test
public void testXmlAccessorOrderInException() throws Exception {
    env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/exception_order.wsdl");
    env.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.fortest.exception.OrderEchoImpl");
    env.put(ToolConstants.CFG_VERBOSE, ToolConstants.CFG_VERBOSE);
    try {
        processor.setEnvironment(env);
        processor.process();
    } catch (Exception e) {
        e.printStackTrace();
    }
    File wsdlFile = new File(output, "exception_order.wsdl");
    assertTrue(wsdlFile.exists());

    Document doc = StaxUtils.read(wsdlFile);
    Map<String, String> map = new HashMap<>();
    map.put("xsd", "http://www.w3.org/2001/XMLSchema");
    map.put("wsdl", "http://schemas.xmlsoap.org/wsdl/");
    map.put("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
    XPathUtils util = new XPathUtils(map);

    Element summary = (Element)util.getValueNode("//xsd:element[@name='summary']", doc);
    Element from = (Element)util.getValueNode("//xsd:element[@name='from']", doc);
    Element id = (Element)util.getValueNode("//xsd:element[@name='id']", doc);
    assertNotNull(summary);
    assertNotNull(from);
    assertNotNull(id);

    Node nd = from.getNextSibling();
    while (nd != null) {
        if (nd == id) {
            from = null;
        } else if (nd == summary) {
            if (from != null) {
                fail("from before summary");
            }
            id = null;
        }
        nd = nd.getNextSibling();
    }
    assertNull(id);
    assertNull(from);
}