Java Code Examples for org.w3c.dom.Text#getWholeText()

The following examples show how to use org.w3c.dom.Text#getWholeText() . 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: DOMStreamReader.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public int next() throws XMLStreamException {
    while(true) {
        int r = _next();
        switch (r) {
        case CHARACTERS:
            // if we are currently at text node, make sure that this is a meaningful text node.
            Node prev = _current.getPreviousSibling();
            if(prev!=null && prev.getNodeType()==Node.TEXT_NODE)
                continue;   // nope. this is just a continuation of previous text that should be invisible

            Text t = (Text)_current;
            wholeText = t.getWholeText();
            if(wholeText.length()==0)
                continue;   // nope. this is empty text.
            return CHARACTERS;
        case START_ELEMENT:
            splitAttributes();
            return START_ELEMENT;
        default:
            return r;
        }
    }
}
 
Example 2
Source File: DOMStreamReader.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public int next() throws XMLStreamException {
    while(true) {
        int r = _next();
        switch (r) {
        case CHARACTERS:
            // if we are currently at text node, make sure that this is a meaningful text node.
            Node prev = _current.getPreviousSibling();
            if(prev!=null && prev.getNodeType()==Node.TEXT_NODE)
                continue;   // nope. this is just a continuation of previous text that should be invisible

            Text t = (Text)_current;
            wholeText = t.getWholeText();
            if(wholeText.length()==0)
                continue;   // nope. this is empty text.
            return CHARACTERS;
        case START_ELEMENT:
            splitAttributes();
            return START_ELEMENT;
        default:
            return r;
        }
    }
}
 
Example 3
Source File: DOMStreamReader.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public int next() throws XMLStreamException {
    while(true) {
        int r = _next();
        switch (r) {
        case CHARACTERS:
            // if we are currently at text node, make sure that this is a meaningful text node.
            Node prev = _current.getPreviousSibling();
            if(prev!=null && prev.getNodeType()==Node.TEXT_NODE)
                continue;   // nope. this is just a continuation of previous text that should be invisible

            Text t = (Text)_current;
            wholeText = t.getWholeText();
            if(wholeText.length()==0)
                continue;   // nope. this is empty text.
            return CHARACTERS;
        case START_ELEMENT:
            splitAttributes();
            return START_ELEMENT;
        default:
            return r;
        }
    }
}
 
Example 4
Source File: DOMStreamReader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public int next() throws XMLStreamException {
    while(true) {
        int r = _next();
        switch (r) {
        case CHARACTERS:
            // if we are currently at text node, make sure that this is a meaningful text node.
            Node prev = _current.getPreviousSibling();
            if(prev!=null && prev.getNodeType()==Node.TEXT_NODE)
                continue;   // nope. this is just a continuation of previous text that should be invisible

            Text t = (Text)_current;
            wholeText = t.getWholeText();
            if(wholeText.length()==0)
                continue;   // nope. this is empty text.
            return CHARACTERS;
        case START_ELEMENT:
            splitAttributes();
            return START_ELEMENT;
        default:
            return r;
        }
    }
}
 
Example 5
Source File: DOMStreamReader.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public int next() throws XMLStreamException {
    while(true) {
        int r = _next();
        switch (r) {
        case CHARACTERS:
            // if we are currently at text node, make sure that this is a meaningful text node.
            Node prev = _current.getPreviousSibling();
            if(prev!=null && prev.getNodeType()==Node.TEXT_NODE)
                continue;   // nope. this is just a continuation of previous text that should be invisible

            Text t = (Text)_current;
            wholeText = t.getWholeText();
            if(wholeText.length()==0)
                continue;   // nope. this is empty text.
            return CHARACTERS;
        case START_ELEMENT:
            splitAttributes();
            return START_ELEMENT;
        default:
            return r;
        }
    }
}
 
Example 6
Source File: DOMStreamReader.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public int next() throws XMLStreamException {
    while(true) {
        int r = _next();
        switch (r) {
        case CHARACTERS:
            // if we are currently at text node, make sure that this is a meaningful text node.
            Node prev = _current.getPreviousSibling();
            if(prev!=null && prev.getNodeType()==Node.TEXT_NODE)
                continue;   // nope. this is just a continuation of previous text that should be invisible

            Text t = (Text)_current;
            wholeText = t.getWholeText();
            if(wholeText.length()==0)
                continue;   // nope. this is empty text.
            return CHARACTERS;
        case START_ELEMENT:
            splitAttributes();
            return START_ELEMENT;
        default:
            return r;
        }
    }
}
 
Example 7
Source File: DOMStreamReader.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public int next() throws XMLStreamException {
    while(true) {
        int r = _next();
        switch (r) {
        case CHARACTERS:
            // if we are currently at text node, make sure that this is a meaningful text node.
            Node prev = _current.getPreviousSibling();
            if(prev!=null && prev.getNodeType()==Node.TEXT_NODE)
                continue;   // nope. this is just a continuation of previous text that should be invisible

            Text t = (Text)_current;
            wholeText = t.getWholeText();
            if(wholeText.length()==0)
                continue;   // nope. this is empty text.
            return CHARACTERS;
        case START_ELEMENT:
            splitAttributes();
            return START_ELEMENT;
        default:
            return r;
        }
    }
}
 
Example 8
Source File: DOMStreamReader.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public int next() throws XMLStreamException {
    while(true) {
        int r = _next();
        switch (r) {
        case CHARACTERS:
            // if we are currently at text node, make sure that this is a meaningful text node.
            Node prev = _current.getPreviousSibling();
            if(prev!=null && prev.getNodeType()==Node.TEXT_NODE)
                continue;   // nope. this is just a continuation of previous text that should be invisible

            Text t = (Text)_current;
            wholeText = t.getWholeText();
            if(wholeText.length()==0)
                continue;   // nope. this is empty text.
            return CHARACTERS;
        case START_ELEMENT:
            splitAttributes();
            return START_ELEMENT;
        default:
            return r;
        }
    }
}
 
Example 9
Source File: DOMStreamReader.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public int next() throws XMLStreamException {
    while(true) {
        int r = _next();
        switch (r) {
        case CHARACTERS:
            // if we are currently at text node, make sure that this is a meaningful text node.
            Node prev = _current.getPreviousSibling();
            if(prev!=null && prev.getNodeType()==Node.TEXT_NODE)
                continue;   // nope. this is just a continuation of previous text that should be invisible

            Text t = (Text)_current;
            wholeText = t.getWholeText();
            if(wholeText.length()==0)
                continue;   // nope. this is empty text.
            return CHARACTERS;
        case START_ELEMENT:
            splitAttributes();
            return START_ELEMENT;
        default:
            return r;
        }
    }
}
 
Example 10
Source File: JSONNormalizedNodeStreamWriter.java    From yangtools with Eclipse Public License 1.0 6 votes vote down vote up
private void writeXmlValue(final Node node) throws IOException {
    Text firstChild = getFirstChildText(node);
    String childNodeText = firstChild != null ? firstChild.getWholeText() : "";
    childNodeText = childNodeText != null ? childNodeText.trim() : "";

    if (NUMBER_PATTERN.matcher(childNodeText).matches()) {
        writer.value(parseNumber(childNodeText));
        return;
    }
    switch (childNodeText) {
        case "null":
            writer.nullValue();
            break;
        case "false":
            writer.value(false);
            break;
        case "true":
            writer.value(true);
            break;
        default:
            writer.value(childNodeText);
    }
}