Java 8 Document - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Document class.

This code example shows how to use the following methods:createElement, createTextNode
 
public class ElementWarningsRenderer { 
    public void renderTo(DslElementDoc elementDoc, String type, Element parent) {
        if (elementDoc.isDeprecated()) {
            Document document = parent.getOwnerDocument();
            Element caution = document.createElement("caution");
            parent.appendChild(caution);
            Element para = document.createElement("para");
            caution.appendChild(para);
            para.appendChild(document.createTextNode(String.format("Note: This %s is ", type)));
            Element link = document.createElement("ulink");
            para.appendChild(link);
            link.setAttribute("url", "../userguide/feature_lifecycle.html");
            link.appendChild(document.createTextNode("deprecated"));
            para.appendChild(document.createTextNode(" and will be removed in the next major version of Gradle."));
        } 
        if (elementDoc.isIncubating()) {
            Document document = parent.getOwnerDocument();
            Element caution = document.createElement("caution");
            parent.appendChild(caution);
8
CodeRank
This code example shows how to use the following methods:getDocumentElement
                    null); 
            SignedInfo si = fac.newSignedInfo(fac.newCanonicalizationMethod(CanonicalizationMethod.INCLUSIVE,
                                                                            (C14NMethodParameterSpec) null), 
                                              fac.newSignatureMethod(SignatureMethod.RSA_SHA1, null),
                                              Collections.singletonList(ref));
            DOMSignContext dsc = new DOMSignContext(privateKey, document.getDocumentElement());
            KeyValue keyValue = keyInfoFactory.newKeyValue(publicKey);
            KeyInfo ki = keyInfoFactory.newKeyInfo(Collections.singletonList(keyValue));
            XMLSignature signature = fac.newXMLSignature(si, ki);
            signature.sign(dsc);
        } catch (Exception e) {
            Logger.warn("Error while signing an XML document.", e);
        } 
 
        return document;
    } 
 
} 
8
CodeRank
This code example shows how to use the following methods:getDocumentElement
	} 
	 
	/** Returns the current values of the schemaLocation attribute */ 
	public synchronized SchemaLocations getCurrentSchemaLocations() { 
		Document doc = getCurrentDocument();
		if (!this.schemaLocations.containsKey(doc)) {
			if (doc != null && doc.getDocumentElement() != null) {
				SchemaLocations schemaLocations = new SchemaLocations();
				schemaLocations.initSchemaLocations(doc.getDocumentElement().getAttributeNS(
						"http://www.w3.org/2001/XMLSchema-instance", "schemaLocation")); 
				this.schemaLocations.put(doc, schemaLocations);
			} 
		} 
		return this.schemaLocations.get(doc);
	} 
 
	/** Removes the first document from the stack */ 
	public Document popDocument() {
		if (!documents.isEmpty()) {
			return documents.pop();
7
CodeRank
This code example shows how to use the following methods:createElement, createTextNode
7
CodeRank
This code example shows how to use the following methods:getDocumentElement
        } 
    } 
 
    @Override 
    protected void xmlModelChanged(Document xmlDoc) {
        Element rootElement = xmlDoc.getDocumentElement();
        if (rootElement != null) {
            mRootTag = rootElement.getTagName();
        } 
 
        initUiRootNode(false /*force*/); 
 
        if (mRootTag != null
                && !mRootTag.equals(mUiRootNode.getDescriptor().getXmlLocalName())) {
            AndroidTargetData data = getTargetData();
            if (data != null) {
                ElementDescriptor descriptor =
                    data.getDrawableDescriptors().getElementDescriptor(mRootTag);
                // Replace top level node now that we know the actual type 
 

7
CodeRank
This code example shows how to use the following methods:createElement, createTextNode
7
CodeRank
This code example shows how to use the following methods:createElement, createTextNode
7
CodeRank
This code example shows how to use the following methods:getDocumentElement
     * Test whether GetCapabilities returns wfs:WFS_Capabilities. 
     */ 
    @Test
    public void testGetCapabilities() { 
        Document doc = getAsDOM("wfs?request=GetCapabilities&version=1.1.0");
        LOGGER.info("WFS GetCapabilities response:\n" + prettyString(doc));
        assertEquals("wfs:WFS_Capabilities", doc.getDocumentElement().getNodeName());
        // make sure non-feature types don't appear in FeatureTypeList 
        assertXpathCount(1, "//wfs:FeatureType", doc);
        ArrayList<String> featureTypeNames = new ArrayList<String>(1);
        featureTypeNames.add(evaluate("//wfs:FeatureType[1]/wfs:Name", doc));
        // ERM 
        assertTrue(featureTypeNames.contains("ex:ERM"));
    } 
 
    /** 
     * Test whether GetFeature returns wfs:FeatureCollection. 
     */ 
    @Test
    public void testGetFeature() { 
7
CodeRank
This code example shows how to use the following methods:createElement, createTextNode
            classNameElement.appendChild(document.createTextNode(className));
            return classNameElement;
        } 
 
        if (className.startsWith("java.")) {
            Element linkElement = document.createElement("ulink");
            linkElement.setAttribute("url", String.format("http://download.oracle.com/javase/1.5.0/docs/api/%s.html",
                    className.replace(".", "/")));
            Element classNameElement = document.createElement("classname");
            classNameElement.appendChild(document.createTextNode(StringUtils.substringAfterLast(className, ".")));
            linkElement.appendChild(classNameElement);
            return linkElement;
        } 
 
        if (className.startsWith("groovy.")) {
            Element linkElement = document.createElement("ulink");
            linkElement.setAttribute("url", String.format("http://groovy.codehaus.org/gapi/%s.html", className.replace(
                    ".", "/"))); 
            Element classNameElement = document.createElement("classname");
            classNameElement.appendChild(document.createTextNode(StringUtils.substringAfterLast(className, ".")));
7
CodeRank
This code example shows how to use the following methods:createElement, createElementNS, createTextNode
    } 
 
    public static Element appendNewElement(Document document, Element parent, String element, Object content, String namespace) {
        Element childElement;
        if (namespace != null) {
            childElement = document.createElementNS(namespace, element);
        } else { 
            childElement = document.createElement(element);
        } 
 
        if (content != null) {
            // TODO: We'll have that on Android 2.2: 
            // childElement.setTextContent(content.toString()); 
            // Meanwhile: 
            childElement.appendChild(document.createTextNode(content.toString()));
        } 
 
        parent.appendChild(childElement);
        return childElement;
    } 
7
CodeRank

Related Java 8 Document Questions & Answers:

Other Java 8 Document Examples

0:	public Document getDomElement(String xml){
1:			Document doc = null;
2:			DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-
1:			Document doc = null;
2:			DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
3:			try {

Read More

8:	XMLParser parser = new XMLParser();
9:	String xml = parser.getXmlFromUrl(URL); // getting XML
10:	Document doc = parser.getDomElement(xml); // getting DOM element
11:	
12:	NodeList nl = doc.getElementsByTagName(KEY_ITEM);

Read More

66:					// parse the xml
67:					try {
68:						Document doc = this.getDomElement(rss_feed_xml);
69:						NodeList nodeList = doc.getElementsByTagName(TAG_CHANNEL);
70:						Element e = (Element) nodeList.item(0);
-
168:					org.jsoup.select.Elements links1 = doc
169:							.select("link[type=application/atom+xml]");
170:					if(links1.size() > 0){
171:						rss_url = links1.get(0).attr("href").toString();	
172:					}
-
169:							.select("link[type=application/atom+xml]");
170:					if(links1.size() > 0){
171:						rss_url = links1.get(0).attr("href").toString();	
172:					}
173:				}
-
177:			}
178:	
179:			// returing RSS url
180:			return rss_url;
181:		}

Read More

See Code Examples for Java 8 Document Methods: