Search in sources :

Example 56 with Text

use of org.w3c.dom.Text in project jdk8u_jdk by JetBrains.

the class Base64 method decode.

/**
     * Method decode
     *
     * Takes the <CODE>Text</CODE> children of the Element and interprets
     * them as input for the <CODE>Base64.decode()</CODE> function.
     *
     * @param element
     * @return the byte obtained of the decoding the element
     * $todo$ not tested yet
     * @throws Base64DecodingException
     */
public static final byte[] decode(Element element) throws Base64DecodingException {
    Node sibling = element.getFirstChild();
    StringBuffer sb = new StringBuffer();
    while (sibling != null) {
        if (sibling.getNodeType() == Node.TEXT_NODE) {
            Text t = (Text) sibling;
            sb.append(t.getData());
        }
        sibling = sibling.getNextSibling();
    }
    return decode(sb.toString());
}
Also used : Node(org.w3c.dom.Node) Text(org.w3c.dom.Text)

Example 57 with Text

use of org.w3c.dom.Text in project jdk8u_jdk by JetBrains.

the class ElementProxy method addTextElement.

/**
     * Method addTextElement
     *
     * @param text
     * @param localname
     */
public void addTextElement(String text, String localname) {
    Element e = XMLUtils.createElementInSignatureSpace(this.doc, localname);
    Text t = this.doc.createTextNode(text);
    e.appendChild(t);
    this.constructionElement.appendChild(e);
    XMLUtils.addReturnToElement(this.constructionElement);
}
Also used : Element(org.w3c.dom.Element) Text(org.w3c.dom.Text)

Example 58 with Text

use of org.w3c.dom.Text in project jdk8u_jdk by JetBrains.

the class IntegrityHmac method engineAddContextToElement.

/**
     * Method engineAddContextToElement
     *
     * @param element
     */
public void engineAddContextToElement(Element element) {
    if (element == null) {
        throw new IllegalArgumentException("null element");
    }
    if (this.HMACOutputLengthSet) {
        Document doc = element.getOwnerDocument();
        Element HMElem = XMLUtils.createElementInSignatureSpace(doc, Constants._TAG_HMACOUTPUTLENGTH);
        Text HMText = doc.createTextNode(Integer.valueOf(this.HMACOutputLength).toString());
        HMElem.appendChild(HMText);
        XMLUtils.addReturnToElement(element);
        element.appendChild(HMElem);
        XMLUtils.addReturnToElement(element);
    }
}
Also used : Element(org.w3c.dom.Element) Text(org.w3c.dom.Text) Document(org.w3c.dom.Document)

Example 59 with Text

use of org.w3c.dom.Text in project webservices-axiom by apache.

the class TestAdoptNodeToSameDocument method runTest.

protected void runTest() throws Throwable {
    DocumentBuilder builder = dbf.newDocumentBuilder();
    Document document = builder.newDocument();
    Element parent = document.createElementNS(null, "test");
    Text node = document.createTextNode("test");
    parent.appendChild(node);
    assertSame(node, document.adoptNode(node));
    assertSame(document, node.getOwnerDocument());
    assertNull(node.getParentNode());
    assertNull(parent.getFirstChild());
}
Also used : DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) Text(org.w3c.dom.Text) Document(org.w3c.dom.Document)

Example 60 with Text

use of org.w3c.dom.Text in project webservices-axiom by apache.

the class TestAdoptNode method runTest.

protected void runTest() throws Throwable {
    DocumentBuilder builder = dbf.newDocumentBuilder();
    Document document1 = builder.newDocument();
    Document document2 = builder.newDocument();
    Element element = document1.createElementNS(null, "test");
    Text child = document1.createTextNode("test");
    element.appendChild(child);
    assertSame(element, document2.adoptNode(element));
    assertSame(document2, element.getOwnerDocument());
    assertSame(child, element.getFirstChild());
    assertSame(document2, element.getFirstChild().getOwnerDocument());
}
Also used : DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) Text(org.w3c.dom.Text) Document(org.w3c.dom.Document)

Aggregations

Text (org.w3c.dom.Text)166 Element (org.w3c.dom.Element)93 Document (org.w3c.dom.Document)64 Node (org.w3c.dom.Node)58 NodeList (org.w3c.dom.NodeList)35 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)23 DocumentBuilder (javax.xml.parsers.DocumentBuilder)22 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)17 IOException (java.io.IOException)14 Attr (org.w3c.dom.Attr)14 InputSource (org.xml.sax.InputSource)11 StringReader (java.io.StringReader)10 SAXException (org.xml.sax.SAXException)8 ArrayList (java.util.ArrayList)7 DOMException (org.w3c.dom.DOMException)7 Test (org.junit.Test)6 DOMSource (javax.xml.transform.dom.DOMSource)5 NamedNodeMap (org.w3c.dom.NamedNodeMap)5 HashMap (java.util.HashMap)4 DocumentFragment (org.w3c.dom.DocumentFragment)4