Java Code Examples for javax.xml.stream.XMLStreamReader#ATTRIBUTE

The following examples show how to use javax.xml.stream.XMLStreamReader#ATTRIBUTE . 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: TimeStaxReading.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
static String eventName(int type) {
  switch (type) {
    case XMLStreamReader.START_DOCUMENT:
      return " startDoc";
    case XMLStreamReader.START_ELEMENT:
      return "startElem";
    case XMLStreamReader.END_DOCUMENT:
      return "   endDoc";
    case XMLStreamReader.END_ELEMENT:
      return "  endElem";
    case XMLStreamReader.ATTRIBUTE:
      return "attribute";
    case XMLStreamReader.CHARACTERS:
      return "    chars";
    default:
      return " " + type;
  }
}
 
Example 2
Source File: StreamReaderBufferCreator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private void storeElementAndChildrenNoEx(XMLStreamReader reader) throws XMLStreamException {
    int depth = 1;
    if (_storeInScopeNamespacesOnElementFragment) {
        storeElementWithInScopeNamespaces(reader);
    } else {
        storeElement(reader);
    }

    while(depth > 0) {
        _eventType = reader.next();
        switch (_eventType) {
            case XMLStreamReader.START_ELEMENT:
                depth++;
                storeElement(reader);
                break;
            case XMLStreamReader.END_ELEMENT:
                depth--;
                storeStructure(T_END);
                break;
            case XMLStreamReader.NAMESPACE:
                storeNamespaceAttributes(reader);
                break;
            case XMLStreamReader.ATTRIBUTE:
                storeAttributes(reader);
                break;
            case XMLStreamReader.SPACE:
            case XMLStreamReader.CHARACTERS:
            case XMLStreamReader.CDATA: {
                storeContentCharacters(T_TEXT_AS_CHAR_ARRAY,
                        reader.getTextCharacters(), reader.getTextStart(),
                        reader.getTextLength());
                break;
            }
            case XMLStreamReader.COMMENT:
                storeComment(reader);
                break;
            case XMLStreamReader.PROCESSING_INSTRUCTION:
                storeProcessingInstruction(reader);
                break;
        }
    }

    /*
     * Move to next item after the end of the element
     * that has been stored
     */
    _eventType = reader.next();
}
 
Example 3
Source File: StreamReaderBufferCreator.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private void storeElementAndChildrenNoEx(XMLStreamReader reader) throws XMLStreamException {
    int depth = 1;
    if (_storeInScopeNamespacesOnElementFragment) {
        storeElementWithInScopeNamespaces(reader);
    } else {
        storeElement(reader);
    }

    while(depth > 0) {
        _eventType = reader.next();
        switch (_eventType) {
            case XMLStreamReader.START_ELEMENT:
                depth++;
                storeElement(reader);
                break;
            case XMLStreamReader.END_ELEMENT:
                depth--;
                storeStructure(T_END);
                break;
            case XMLStreamReader.NAMESPACE:
                storeNamespaceAttributes(reader);
                break;
            case XMLStreamReader.ATTRIBUTE:
                storeAttributes(reader);
                break;
            case XMLStreamReader.SPACE:
            case XMLStreamReader.CHARACTERS:
            case XMLStreamReader.CDATA: {
                storeContentCharacters(T_TEXT_AS_CHAR_ARRAY,
                        reader.getTextCharacters(), reader.getTextStart(),
                        reader.getTextLength());
                break;
            }
            case XMLStreamReader.COMMENT:
                storeComment(reader);
                break;
            case XMLStreamReader.PROCESSING_INSTRUCTION:
                storeProcessingInstruction(reader);
                break;
        }
    }

    /*
     * Move to next item after the end of the element
     * that has been stored
     */
    _eventType = reader.next();
}
 
Example 4
Source File: StreamReaderBufferCreator.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private void storeElementAndChildrenEx(XMLStreamReaderEx reader) throws XMLStreamException {
    int depth = 1;
    if (_storeInScopeNamespacesOnElementFragment) {
        storeElementWithInScopeNamespaces(reader);
    } else {
        storeElement(reader);
    }

    while(depth > 0) {
        _eventType = reader.next();
        switch (_eventType) {
            case XMLStreamReader.START_ELEMENT:
                depth++;
                storeElement(reader);
                break;
            case XMLStreamReader.END_ELEMENT:
                depth--;
                storeStructure(T_END);
                break;
            case XMLStreamReader.NAMESPACE:
                storeNamespaceAttributes(reader);
                break;
            case XMLStreamReader.ATTRIBUTE:
                storeAttributes(reader);
                break;
            case XMLStreamReader.SPACE:
            case XMLStreamReader.CHARACTERS:
            case XMLStreamReader.CDATA: {
                CharSequence c = reader.getPCDATA();
                if (c instanceof Base64Data) {
                    storeStructure(T_TEXT_AS_OBJECT);
                    //Instead of clone the Base64Data, the original Base64Data instance is used here to preserve the DataHandler
                    storeContentObject(c);
                } else {
                    storeContentCharacters(T_TEXT_AS_CHAR_ARRAY,
                            reader.getTextCharacters(), reader.getTextStart(),
                            reader.getTextLength());
                }
                break;
            }
            case XMLStreamReader.COMMENT:
                storeComment(reader);
                break;
            case XMLStreamReader.PROCESSING_INSTRUCTION:
                storeProcessingInstruction(reader);
                break;
        }
    }

    /*
     * Move to next item after the end of the element
     * that has been stored
     */
    _eventType = reader.next();
}
 
Example 5
Source File: StreamReaderBufferCreator.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private void storeElementAndChildrenNoEx(XMLStreamReader reader) throws XMLStreamException {
    int depth = 1;
    if (_storeInScopeNamespacesOnElementFragment) {
        storeElementWithInScopeNamespaces(reader);
    } else {
        storeElement(reader);
    }

    while(depth > 0) {
        _eventType = reader.next();
        switch (_eventType) {
            case XMLStreamReader.START_ELEMENT:
                depth++;
                storeElement(reader);
                break;
            case XMLStreamReader.END_ELEMENT:
                depth--;
                storeStructure(T_END);
                break;
            case XMLStreamReader.NAMESPACE:
                storeNamespaceAttributes(reader);
                break;
            case XMLStreamReader.ATTRIBUTE:
                storeAttributes(reader);
                break;
            case XMLStreamReader.SPACE:
            case XMLStreamReader.CHARACTERS:
            case XMLStreamReader.CDATA: {
                storeContentCharacters(T_TEXT_AS_CHAR_ARRAY,
                        reader.getTextCharacters(), reader.getTextStart(),
                        reader.getTextLength());
                break;
            }
            case XMLStreamReader.COMMENT:
                storeComment(reader);
                break;
            case XMLStreamReader.PROCESSING_INSTRUCTION:
                storeProcessingInstruction(reader);
                break;
        }
    }

    /*
     * Move to next item after the end of the element
     * that has been stored
     */
    _eventType = reader.next();
}
 
Example 6
Source File: StreamReaderBufferCreator.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private void storeElementAndChildrenEx(XMLStreamReaderEx reader) throws XMLStreamException {
    int depth = 1;
    if (_storeInScopeNamespacesOnElementFragment) {
        storeElementWithInScopeNamespaces(reader);
    } else {
        storeElement(reader);
    }

    while(depth > 0) {
        _eventType = reader.next();
        switch (_eventType) {
            case XMLStreamReader.START_ELEMENT:
                depth++;
                storeElement(reader);
                break;
            case XMLStreamReader.END_ELEMENT:
                depth--;
                storeStructure(T_END);
                break;
            case XMLStreamReader.NAMESPACE:
                storeNamespaceAttributes(reader);
                break;
            case XMLStreamReader.ATTRIBUTE:
                storeAttributes(reader);
                break;
            case XMLStreamReader.SPACE:
            case XMLStreamReader.CHARACTERS:
            case XMLStreamReader.CDATA: {
                CharSequence c = reader.getPCDATA();
                if (c instanceof Base64Data) {
                    storeStructure(T_TEXT_AS_OBJECT);
                    //Instead of clone the Base64Data, the original Base64Data instance is used here to preserve the DataHandler
                    storeContentObject(c);
                } else {
                    storeContentCharacters(T_TEXT_AS_CHAR_ARRAY,
                            reader.getTextCharacters(), reader.getTextStart(),
                            reader.getTextLength());
                }
                break;
            }
            case XMLStreamReader.COMMENT:
                storeComment(reader);
                break;
            case XMLStreamReader.PROCESSING_INSTRUCTION:
                storeProcessingInstruction(reader);
                break;
        }
    }

    /*
     * Move to next item after the end of the element
     * that has been stored
     */
    _eventType = reader.next();
}
 
Example 7
Source File: StreamReaderBufferCreator.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private void storeElementAndChildrenNoEx(XMLStreamReader reader) throws XMLStreamException {
    int depth = 1;
    if (_storeInScopeNamespacesOnElementFragment) {
        storeElementWithInScopeNamespaces(reader);
    } else {
        storeElement(reader);
    }

    while(depth > 0) {
        _eventType = reader.next();
        switch (_eventType) {
            case XMLStreamReader.START_ELEMENT:
                depth++;
                storeElement(reader);
                break;
            case XMLStreamReader.END_ELEMENT:
                depth--;
                storeStructure(T_END);
                break;
            case XMLStreamReader.NAMESPACE:
                storeNamespaceAttributes(reader);
                break;
            case XMLStreamReader.ATTRIBUTE:
                storeAttributes(reader);
                break;
            case XMLStreamReader.SPACE:
            case XMLStreamReader.CHARACTERS:
            case XMLStreamReader.CDATA: {
                storeContentCharacters(T_TEXT_AS_CHAR_ARRAY,
                        reader.getTextCharacters(), reader.getTextStart(),
                        reader.getTextLength());
                break;
            }
            case XMLStreamReader.COMMENT:
                storeComment(reader);
                break;
            case XMLStreamReader.PROCESSING_INSTRUCTION:
                storeProcessingInstruction(reader);
                break;
        }
    }

    /*
     * Move to next item after the end of the element
     * that has been stored
     */
    _eventType = reader.next();
}
 
Example 8
Source File: StreamReaderBufferCreator.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private void storeElementAndChildrenEx(XMLStreamReaderEx reader) throws XMLStreamException {
    int depth = 1;
    if (_storeInScopeNamespacesOnElementFragment) {
        storeElementWithInScopeNamespaces(reader);
    } else {
        storeElement(reader);
    }

    while(depth > 0) {
        _eventType = reader.next();
        switch (_eventType) {
            case XMLStreamReader.START_ELEMENT:
                depth++;
                storeElement(reader);
                break;
            case XMLStreamReader.END_ELEMENT:
                depth--;
                storeStructure(T_END);
                break;
            case XMLStreamReader.NAMESPACE:
                storeNamespaceAttributes(reader);
                break;
            case XMLStreamReader.ATTRIBUTE:
                storeAttributes(reader);
                break;
            case XMLStreamReader.SPACE:
            case XMLStreamReader.CHARACTERS:
            case XMLStreamReader.CDATA: {
                CharSequence c = reader.getPCDATA();
                if (c instanceof Base64Data) {
                    storeStructure(T_TEXT_AS_OBJECT);
                    //Instead of clone the Base64Data, the original Base64Data instance is used here to preserve the DataHandler
                    storeContentObject(c);
                } else {
                    storeContentCharacters(T_TEXT_AS_CHAR_ARRAY,
                            reader.getTextCharacters(), reader.getTextStart(),
                            reader.getTextLength());
                }
                break;
            }
            case XMLStreamReader.COMMENT:
                storeComment(reader);
                break;
            case XMLStreamReader.PROCESSING_INSTRUCTION:
                storeProcessingInstruction(reader);
                break;
        }
    }

    /*
     * Move to next item after the end of the element
     * that has been stored
     */
    _eventType = reader.next();
}
 
Example 9
Source File: StreamReaderBufferCreator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void storeElementAndChildrenNoEx(XMLStreamReader reader) throws XMLStreamException {
    int depth = 1;
    if (_storeInScopeNamespacesOnElementFragment) {
        storeElementWithInScopeNamespaces(reader);
    } else {
        storeElement(reader);
    }

    while(depth > 0) {
        _eventType = reader.next();
        switch (_eventType) {
            case XMLStreamReader.START_ELEMENT:
                depth++;
                storeElement(reader);
                break;
            case XMLStreamReader.END_ELEMENT:
                depth--;
                storeStructure(T_END);
                break;
            case XMLStreamReader.NAMESPACE:
                storeNamespaceAttributes(reader);
                break;
            case XMLStreamReader.ATTRIBUTE:
                storeAttributes(reader);
                break;
            case XMLStreamReader.SPACE:
            case XMLStreamReader.CHARACTERS:
            case XMLStreamReader.CDATA: {
                storeContentCharacters(T_TEXT_AS_CHAR_ARRAY,
                        reader.getTextCharacters(), reader.getTextStart(),
                        reader.getTextLength());
                break;
            }
            case XMLStreamReader.COMMENT:
                storeComment(reader);
                break;
            case XMLStreamReader.PROCESSING_INSTRUCTION:
                storeProcessingInstruction(reader);
                break;
        }
    }

    /*
     * Move to next item after the end of the element
     * that has been stored
     */
    _eventType = reader.next();
}
 
Example 10
Source File: StreamReaderBufferCreator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void storeElementAndChildrenEx(XMLStreamReaderEx reader) throws XMLStreamException {
    int depth = 1;
    if (_storeInScopeNamespacesOnElementFragment) {
        storeElementWithInScopeNamespaces(reader);
    } else {
        storeElement(reader);
    }

    while(depth > 0) {
        _eventType = reader.next();
        switch (_eventType) {
            case XMLStreamReader.START_ELEMENT:
                depth++;
                storeElement(reader);
                break;
            case XMLStreamReader.END_ELEMENT:
                depth--;
                storeStructure(T_END);
                break;
            case XMLStreamReader.NAMESPACE:
                storeNamespaceAttributes(reader);
                break;
            case XMLStreamReader.ATTRIBUTE:
                storeAttributes(reader);
                break;
            case XMLStreamReader.SPACE:
            case XMLStreamReader.CHARACTERS:
            case XMLStreamReader.CDATA: {
                CharSequence c = reader.getPCDATA();
                if (c instanceof Base64Data) {
                    storeStructure(T_TEXT_AS_OBJECT);
                    //Instead of clone the Base64Data, the original Base64Data instance is used here to preserve the DataHandler
                    storeContentObject(c);
                } else {
                    storeContentCharacters(T_TEXT_AS_CHAR_ARRAY,
                            reader.getTextCharacters(), reader.getTextStart(),
                            reader.getTextLength());
                }
                break;
            }
            case XMLStreamReader.COMMENT:
                storeComment(reader);
                break;
            case XMLStreamReader.PROCESSING_INSTRUCTION:
                storeProcessingInstruction(reader);
                break;
        }
    }

    /*
     * Move to next item after the end of the element
     * that has been stored
     */
    _eventType = reader.next();
}
 
Example 11
Source File: StreamReaderBufferCreator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private void storeElementAndChildrenEx(XMLStreamReaderEx reader) throws XMLStreamException {
    int depth = 1;
    if (_storeInScopeNamespacesOnElementFragment) {
        storeElementWithInScopeNamespaces(reader);
    } else {
        storeElement(reader);
    }

    while(depth > 0) {
        _eventType = reader.next();
        switch (_eventType) {
            case XMLStreamReader.START_ELEMENT:
                depth++;
                storeElement(reader);
                break;
            case XMLStreamReader.END_ELEMENT:
                depth--;
                storeStructure(T_END);
                break;
            case XMLStreamReader.NAMESPACE:
                storeNamespaceAttributes(reader);
                break;
            case XMLStreamReader.ATTRIBUTE:
                storeAttributes(reader);
                break;
            case XMLStreamReader.SPACE:
            case XMLStreamReader.CHARACTERS:
            case XMLStreamReader.CDATA: {
                CharSequence c = reader.getPCDATA();
                if (c instanceof Base64Data) {
                    storeStructure(T_TEXT_AS_OBJECT);
                    //Instead of clone the Base64Data, the original Base64Data instance is used here to preserve the DataHandler
                    storeContentObject(c);
                } else {
                    storeContentCharacters(T_TEXT_AS_CHAR_ARRAY,
                            reader.getTextCharacters(), reader.getTextStart(),
                            reader.getTextLength());
                }
                break;
            }
            case XMLStreamReader.COMMENT:
                storeComment(reader);
                break;
            case XMLStreamReader.PROCESSING_INSTRUCTION:
                storeProcessingInstruction(reader);
                break;
        }
    }

    /*
     * Move to next item after the end of the element
     * that has been stored
     */
    _eventType = reader.next();
}
 
Example 12
Source File: StreamReaderBufferCreator.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private void storeElementAndChildrenNoEx(XMLStreamReader reader) throws XMLStreamException {
    int depth = 1;
    if (_storeInScopeNamespacesOnElementFragment) {
        storeElementWithInScopeNamespaces(reader);
    } else {
        storeElement(reader);
    }

    while(depth > 0) {
        _eventType = reader.next();
        switch (_eventType) {
            case XMLStreamReader.START_ELEMENT:
                depth++;
                storeElement(reader);
                break;
            case XMLStreamReader.END_ELEMENT:
                depth--;
                storeStructure(T_END);
                break;
            case XMLStreamReader.NAMESPACE:
                storeNamespaceAttributes(reader);
                break;
            case XMLStreamReader.ATTRIBUTE:
                storeAttributes(reader);
                break;
            case XMLStreamReader.SPACE:
            case XMLStreamReader.CHARACTERS:
            case XMLStreamReader.CDATA: {
                storeContentCharacters(T_TEXT_AS_CHAR_ARRAY,
                        reader.getTextCharacters(), reader.getTextStart(),
                        reader.getTextLength());
                break;
            }
            case XMLStreamReader.COMMENT:
                storeComment(reader);
                break;
            case XMLStreamReader.PROCESSING_INSTRUCTION:
                storeProcessingInstruction(reader);
                break;
        }
    }

    /*
     * Move to next item after the end of the element
     * that has been stored
     */
    _eventType = reader.next();
}
 
Example 13
Source File: StreamReaderBufferCreator.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private void storeElementAndChildrenEx(XMLStreamReaderEx reader) throws XMLStreamException {
    int depth = 1;
    if (_storeInScopeNamespacesOnElementFragment) {
        storeElementWithInScopeNamespaces(reader);
    } else {
        storeElement(reader);
    }

    while(depth > 0) {
        _eventType = reader.next();
        switch (_eventType) {
            case XMLStreamReader.START_ELEMENT:
                depth++;
                storeElement(reader);
                break;
            case XMLStreamReader.END_ELEMENT:
                depth--;
                storeStructure(T_END);
                break;
            case XMLStreamReader.NAMESPACE:
                storeNamespaceAttributes(reader);
                break;
            case XMLStreamReader.ATTRIBUTE:
                storeAttributes(reader);
                break;
            case XMLStreamReader.SPACE:
            case XMLStreamReader.CHARACTERS:
            case XMLStreamReader.CDATA: {
                CharSequence c = reader.getPCDATA();
                if (c instanceof Base64Data) {
                    storeStructure(T_TEXT_AS_OBJECT);
                    //Instead of clone the Base64Data, the original Base64Data instance is used here to preserve the DataHandler
                    storeContentObject(c);
                } else {
                    storeContentCharacters(T_TEXT_AS_CHAR_ARRAY,
                            reader.getTextCharacters(), reader.getTextStart(),
                            reader.getTextLength());
                }
                break;
            }
            case XMLStreamReader.COMMENT:
                storeComment(reader);
                break;
            case XMLStreamReader.PROCESSING_INSTRUCTION:
                storeProcessingInstruction(reader);
                break;
        }
    }

    /*
     * Move to next item after the end of the element
     * that has been stored
     */
    _eventType = reader.next();
}
 
Example 14
Source File: StreamReaderBufferCreator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private void storeElementAndChildrenNoEx(XMLStreamReader reader) throws XMLStreamException {
    int depth = 1;
    if (_storeInScopeNamespacesOnElementFragment) {
        storeElementWithInScopeNamespaces(reader);
    } else {
        storeElement(reader);
    }

    while(depth > 0) {
        _eventType = reader.next();
        switch (_eventType) {
            case XMLStreamReader.START_ELEMENT:
                depth++;
                storeElement(reader);
                break;
            case XMLStreamReader.END_ELEMENT:
                depth--;
                storeStructure(T_END);
                break;
            case XMLStreamReader.NAMESPACE:
                storeNamespaceAttributes(reader);
                break;
            case XMLStreamReader.ATTRIBUTE:
                storeAttributes(reader);
                break;
            case XMLStreamReader.SPACE:
            case XMLStreamReader.CHARACTERS:
            case XMLStreamReader.CDATA: {
                storeContentCharacters(T_TEXT_AS_CHAR_ARRAY,
                        reader.getTextCharacters(), reader.getTextStart(),
                        reader.getTextLength());
                break;
            }
            case XMLStreamReader.COMMENT:
                storeComment(reader);
                break;
            case XMLStreamReader.PROCESSING_INSTRUCTION:
                storeProcessingInstruction(reader);
                break;
        }
    }

    /*
     * Move to next item after the end of the element
     * that has been stored
     */
    _eventType = reader.next();
}
 
Example 15
Source File: StreamReaderBufferCreator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private void storeElementAndChildrenEx(XMLStreamReaderEx reader) throws XMLStreamException {
    int depth = 1;
    if (_storeInScopeNamespacesOnElementFragment) {
        storeElementWithInScopeNamespaces(reader);
    } else {
        storeElement(reader);
    }

    while(depth > 0) {
        _eventType = reader.next();
        switch (_eventType) {
            case XMLStreamReader.START_ELEMENT:
                depth++;
                storeElement(reader);
                break;
            case XMLStreamReader.END_ELEMENT:
                depth--;
                storeStructure(T_END);
                break;
            case XMLStreamReader.NAMESPACE:
                storeNamespaceAttributes(reader);
                break;
            case XMLStreamReader.ATTRIBUTE:
                storeAttributes(reader);
                break;
            case XMLStreamReader.SPACE:
            case XMLStreamReader.CHARACTERS:
            case XMLStreamReader.CDATA: {
                CharSequence c = reader.getPCDATA();
                if (c instanceof Base64Data) {
                    storeStructure(T_TEXT_AS_OBJECT);
                    //Instead of clone the Base64Data, the original Base64Data instance is used here to preserve the DataHandler
                    storeContentObject(c);
                } else {
                    storeContentCharacters(T_TEXT_AS_CHAR_ARRAY,
                            reader.getTextCharacters(), reader.getTextStart(),
                            reader.getTextLength());
                }
                break;
            }
            case XMLStreamReader.COMMENT:
                storeComment(reader);
                break;
            case XMLStreamReader.PROCESSING_INSTRUCTION:
                storeProcessingInstruction(reader);
                break;
        }
    }

    /*
     * Move to next item after the end of the element
     * that has been stored
     */
    _eventType = reader.next();
}
 
Example 16
Source File: StreamReaderBufferCreator.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private void storeElementAndChildrenNoEx(XMLStreamReader reader) throws XMLStreamException {
    int depth = 1;
    if (_storeInScopeNamespacesOnElementFragment) {
        storeElementWithInScopeNamespaces(reader);
    } else {
        storeElement(reader);
    }

    while(depth > 0) {
        _eventType = reader.next();
        switch (_eventType) {
            case XMLStreamReader.START_ELEMENT:
                depth++;
                storeElement(reader);
                break;
            case XMLStreamReader.END_ELEMENT:
                depth--;
                storeStructure(T_END);
                break;
            case XMLStreamReader.NAMESPACE:
                storeNamespaceAttributes(reader);
                break;
            case XMLStreamReader.ATTRIBUTE:
                storeAttributes(reader);
                break;
            case XMLStreamReader.SPACE:
            case XMLStreamReader.CHARACTERS:
            case XMLStreamReader.CDATA: {
                storeContentCharacters(T_TEXT_AS_CHAR_ARRAY,
                        reader.getTextCharacters(), reader.getTextStart(),
                        reader.getTextLength());
                break;
            }
            case XMLStreamReader.COMMENT:
                storeComment(reader);
                break;
            case XMLStreamReader.PROCESSING_INSTRUCTION:
                storeProcessingInstruction(reader);
                break;
        }
    }

    /*
     * Move to next item after the end of the element
     * that has been stored
     */
    _eventType = reader.next();
}
 
Example 17
Source File: StreamReaderBufferCreator.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private void storeElementAndChildrenEx(XMLStreamReaderEx reader) throws XMLStreamException {
    int depth = 1;
    if (_storeInScopeNamespacesOnElementFragment) {
        storeElementWithInScopeNamespaces(reader);
    } else {
        storeElement(reader);
    }

    while(depth > 0) {
        _eventType = reader.next();
        switch (_eventType) {
            case XMLStreamReader.START_ELEMENT:
                depth++;
                storeElement(reader);
                break;
            case XMLStreamReader.END_ELEMENT:
                depth--;
                storeStructure(T_END);
                break;
            case XMLStreamReader.NAMESPACE:
                storeNamespaceAttributes(reader);
                break;
            case XMLStreamReader.ATTRIBUTE:
                storeAttributes(reader);
                break;
            case XMLStreamReader.SPACE:
            case XMLStreamReader.CHARACTERS:
            case XMLStreamReader.CDATA: {
                CharSequence c = reader.getPCDATA();
                if (c instanceof Base64Data) {
                    storeStructure(T_TEXT_AS_OBJECT);
                    //Instead of clone the Base64Data, the original Base64Data instance is used here to preserve the DataHandler
                    storeContentObject(c);
                } else {
                    storeContentCharacters(T_TEXT_AS_CHAR_ARRAY,
                            reader.getTextCharacters(), reader.getTextStart(),
                            reader.getTextLength());
                }
                break;
            }
            case XMLStreamReader.COMMENT:
                storeComment(reader);
                break;
            case XMLStreamReader.PROCESSING_INSTRUCTION:
                storeProcessingInstruction(reader);
                break;
        }
    }

    /*
     * Move to next item after the end of the element
     * that has been stored
     */
    _eventType = reader.next();
}