Java Code Examples for javax.xml.stream.XMLStreamReader#isCharacters()
The following examples show how to use
javax.xml.stream.XMLStreamReader#isCharacters() .
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: XmlErrorDocumentDeserializer.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private void handleInnerError(final XMLStreamReader reader, final ODataErrorContext errorContext) throws XMLStreamException { StringBuilder sb = new StringBuilder(); while (notFinished(reader, FormatXml.M_INNER_ERROR)) { if (reader.hasName() && !FormatXml.M_INNER_ERROR.equals(reader.getLocalName())) { sb.append("<"); if (reader.isEndElement()) { sb.append("/"); } sb.append(reader.getLocalName()).append(">"); } else if (reader.isCharacters()) { sb.append(reader.getText()); } reader.next(); } errorContext.setInnerError(sb.toString()); }
Example 2
Source File: AtomServiceDocumentConsumer.java From cloud-odata-java with Apache License 2.0 | 6 votes |
private ExtensionElementImpl parseElement(final XMLStreamReader reader) throws XMLStreamException, EntityProviderException { List<ExtensionElement> extensionElements = new ArrayList<ExtensionElement>(); ExtensionElementImpl extElement = new ExtensionElementImpl().setName(reader.getLocalName()).setNamespace(reader.getNamespaceURI()).setPrefix(reader.getPrefix()); extElement.setAttributes(parseAttribute(reader)); while (reader.hasNext() && !(reader.isEndElement() && extElement.getName() != null && extElement.getName().equals(reader.getLocalName()))) { reader.next(); if (reader.isCharacters()) { extElement.setText(reader.getText()); } else if (reader.isStartElement()) { extensionElements.add(parseExtensionElement(reader)); } } extElement.setElements(extensionElements); if (extElement.getText() == null && extElement.getAttributes().isEmpty() && extElement.getElements().isEmpty()) { throw new EntityProviderException(EntityProviderException.INVALID_STATE.addContent("Invalid extension element")); } return extElement; }
Example 3
Source File: MusicPlayer.java From MusicPlayer with MIT License | 5 votes |
private static int xmlMusicDirFileNumFinder() { try { // Creates reader for xml file. XMLInputFactory factory = XMLInputFactory.newInstance(); factory.setProperty("javax.xml.stream.isCoalescing", true); FileInputStream is = new FileInputStream(new File(Resources.JAR + "library.xml")); XMLStreamReader reader = factory.createXMLStreamReader(is, "UTF-8"); String element = null; String fileNum = null; // Loops through xml file looking for the music directory file path. while(reader.hasNext()) { reader.next(); if (reader.isWhiteSpace()) { continue; } else if (reader.isStartElement()) { element = reader.getName().getLocalPart(); } else if (reader.isCharacters() && element.equals("fileNum")) { fileNum = reader.getText(); break; } } // Closes xml reader. reader.close(); // Converts the file number to an int and returns the value. return Integer.parseInt(fileNum); } catch (Exception e) { e.printStackTrace(); return 0; } }
Example 4
Source File: AtomServiceDocumentConsumer.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private ExtensionElementImpl parseElement(final XMLStreamReader reader) throws XMLStreamException, EntityProviderException { List<ExtensionElement> extensionElements = new ArrayList<ExtensionElement>(); ExtensionElementImpl extElement = new ExtensionElementImpl().setName(reader.getLocalName()).setNamespace(reader.getNamespaceURI()).setPrefix( reader.getPrefix()); extElement.setAttributes(parseAttribute(reader)); while (reader.hasNext() && !(reader.isEndElement() && extElement.getName() != null && extElement.getName() .equals(reader.getLocalName()))) { reader.next(); if (reader.isStartElement()) { extensionElements.add(parseExtensionElement(reader)); } else if (reader.isCharacters()) { String extElementText = ""; do { extElementText = extElementText + reader.getText(); reader.next(); } while (reader.isCharacters()); extElement.setText(extElementText); } } extElement.setElements(extensionElements); if (extElement.getText() == null && extElement.getAttributes().isEmpty() && extElement.getElements().isEmpty()) { throw new EntityProviderException(EntityProviderException.INVALID_STATE.addContent("Invalid extension element")); } return extElement; }
Example 5
Source File: EdmParser.java From cloud-odata-java with Apache License 2.0 | 5 votes |
private AnnotationElement readAnnotationElement(final XMLStreamReader reader) throws XMLStreamException { AnnotationElement aElement = new AnnotationElement(); List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>(); List<AnnotationAttribute> annotationAttributes = new ArrayList<AnnotationAttribute>(); aElement.setName(reader.getLocalName()); String elementNamespace = reader.getNamespaceURI(); if (!Edm.NAMESPACE_EDM_2008_09.equals(elementNamespace)) { aElement.setPrefix(reader.getPrefix()); aElement.setNamespace(elementNamespace); } for (int i = 0; i < reader.getAttributeCount(); i++) { AnnotationAttribute annotationAttribute = new AnnotationAttribute(); annotationAttribute.setText(reader.getAttributeValue(i)); annotationAttribute.setName(reader.getAttributeLocalName(i)); annotationAttribute.setPrefix(reader.getAttributePrefix(i)); String namespace = reader.getAttributeNamespace(i); if (namespace != null && !isDefaultNamespace(namespace)) { annotationAttribute.setNamespace(namespace); } annotationAttributes.add(annotationAttribute); } aElement.setAttributes(annotationAttributes); while (reader.hasNext() && !(reader.isEndElement() && aElement.getName() != null && aElement.getName().equals(reader.getLocalName()))) { reader.next(); if (reader.isStartElement()) { annotationElements.add(readAnnotationElement(reader)); } else if (reader.isCharacters()) { aElement.setText(reader.getText()); } } if (!annotationElements.isEmpty()) { aElement.setChildElements(annotationElements); } return aElement; }
Example 6
Source File: XMLEditor.java From MusicPlayer with MIT License | 5 votes |
private static int xmlLastIdAssignedFinder() { try { // Creates reader for xml file. XMLInputFactory factory = XMLInputFactory.newInstance(); factory.setProperty("javax.xml.stream.isCoalescing", true); FileInputStream is = new FileInputStream(new File(Resources.JAR + "library.xml")); XMLStreamReader reader = factory.createXMLStreamReader(is, "UTF-8"); String element = null; String lastId = null; // Loops through xml file looking for the music directory file path. while(reader.hasNext()) { reader.next(); if (reader.isWhiteSpace()) { continue; } else if (reader.isStartElement()) { element = reader.getName().getLocalPart(); } else if (reader.isCharacters() && element.equals("lastId")) { lastId = reader.getText(); break; } } // Closes xml reader. reader.close(); // Converts the file number to an int and returns the value. return Integer.parseInt(lastId); } catch (Exception e) { e.printStackTrace(); return 0; } }
Example 7
Source File: XMLEditor.java From MusicPlayer with MIT License | 5 votes |
private static void xmlSongsFilePathFinder() { try { // Creates reader for xml file. XMLInputFactory factory = XMLInputFactory.newInstance(); factory.setProperty("javax.xml.stream.isCoalescing", true); FileInputStream is = new FileInputStream(new File(Resources.JAR + "library.xml")); XMLStreamReader reader = factory.createXMLStreamReader(is, "UTF-8"); String element = null; String songLocation; // Loops through xml file looking for song titles. // Stores the song title in the xmlSongsFileNames array list. while(reader.hasNext()) { reader.next(); if (reader.isWhiteSpace()) { continue; } else if (reader.isStartElement()) { element = reader.getName().getLocalPart(); } else if (reader.isCharacters() && element.equals("location")) { // Retrieves the song location and adds it to the corresponding array list. songLocation = reader.getText(); xmlSongsFilePaths.add(songLocation); // Retrieves the file name from the file path and adds it to the xmlSongsFileNames array list. int i = songLocation.lastIndexOf("\\"); String songFileName = songLocation.substring(i + 1, songLocation.length()); xmlSongsFileNames.add(songFileName); } } // Closes xml reader. reader.close(); } catch (Exception e) { e.printStackTrace(); } }
Example 8
Source File: AntXmlParser.java From rich-test-results with Apache License 2.0 | 5 votes |
private String getElementContent(XMLStreamReader xmlStreamReader, String elementName) throws XMLStreamException { String tagName = null; StringBuilder stringBuilder = new StringBuilder(); do { xmlStreamReader.next(); if (xmlStreamReader.hasName()) { tagName = xmlStreamReader.getName().toString(); } else if (xmlStreamReader.isCharacters()) { String text = xmlStreamReader.getText(); stringBuilder.append(text); } } while (!xmlStreamReader.isEndElement() || !elementName.equals(tagName)); return stringBuilder.toString(); }
Example 9
Source File: XmlEntryConsumer.java From cloud-odata-java with Apache License 2.0 | 5 votes |
private void readId(final XMLStreamReader reader) throws EntityProviderException, XMLStreamException { reader.require(XMLStreamConstants.START_ELEMENT, Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_ID); reader.next(); if (reader.isCharacters()) { entryMetadata.setId(reader.getText()); } reader.nextTag(); reader.require(XMLStreamConstants.END_ELEMENT, Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_ID); }
Example 10
Source File: MusicPlayer.java From MusicPlayer with MIT License | 5 votes |
private static Path xmlMusicDirPathFinder() { try { // Creates reader for xml file. XMLInputFactory factory = XMLInputFactory.newInstance(); factory.setProperty("javax.xml.stream.isCoalescing", true); FileInputStream is = new FileInputStream(new File(Resources.JAR + "library.xml")); XMLStreamReader reader = factory.createXMLStreamReader(is, "UTF-8"); String element = null; String path = null; // Loops through xml file looking for the music directory file path. while(reader.hasNext()) { reader.next(); if (reader.isWhiteSpace()) { continue; } else if (reader.isStartElement()) { element = reader.getName().getLocalPart(); } else if (reader.isCharacters() && element.equals("path")) { path = reader.getText(); break; } } // Closes xml reader. reader.close(); return Paths.get(path); } catch (Exception e) { e.printStackTrace(); return null; } }
Example 11
Source File: BpmnXMLUtil.java From flowable-engine with Apache License 2.0 | 5 votes |
public static ExtensionElement parseExtensionElement(XMLStreamReader xtr) throws Exception { ExtensionElement extensionElement = new ExtensionElement(); extensionElement.setName(xtr.getLocalName()); if (StringUtils.isNotEmpty(xtr.getNamespaceURI())) { extensionElement.setNamespace(xtr.getNamespaceURI()); } if (StringUtils.isNotEmpty(xtr.getPrefix())) { extensionElement.setNamespacePrefix(xtr.getPrefix()); } for (int i = 0; i < xtr.getAttributeCount(); i++) { ExtensionAttribute extensionAttribute = new ExtensionAttribute(); extensionAttribute.setName(xtr.getAttributeLocalName(i)); extensionAttribute.setValue(xtr.getAttributeValue(i)); if (StringUtils.isNotEmpty(xtr.getAttributeNamespace(i))) { extensionAttribute.setNamespace(xtr.getAttributeNamespace(i)); } if (StringUtils.isNotEmpty(xtr.getAttributePrefix(i))) { extensionAttribute.setNamespacePrefix(xtr.getAttributePrefix(i)); } extensionElement.addAttribute(extensionAttribute); } boolean readyWithExtensionElement = false; while (!readyWithExtensionElement && xtr.hasNext()) { xtr.next(); if (xtr.isCharacters() || XMLStreamReader.CDATA == xtr.getEventType()) { if (StringUtils.isNotEmpty(xtr.getText().trim())) { extensionElement.setElementText(xtr.getText().trim()); } } else if (xtr.isStartElement()) { ExtensionElement childExtensionElement = parseExtensionElement(xtr); extensionElement.addChildElement(childExtensionElement); } else if (xtr.isEndElement() && extensionElement.getName().equalsIgnoreCase(xtr.getLocalName())) { readyWithExtensionElement = true; } } return extensionElement; }
Example 12
Source File: BaseBpmnXMLConverter.java From flowable-engine with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") protected ExtensionElement parseExtensionElement(XMLStreamReader xtr) throws Exception { ExtensionElement extensionElement = new ExtensionElement(); extensionElement.setName(xtr.getLocalName()); if (StringUtils.isNotEmpty(xtr.getNamespaceURI())) { extensionElement.setNamespace(xtr.getNamespaceURI()); } if (StringUtils.isNotEmpty(xtr.getPrefix())) { extensionElement.setNamespacePrefix(xtr.getPrefix()); } BpmnXMLUtil.addCustomAttributes(xtr, extensionElement, defaultElementAttributes); boolean readyWithExtensionElement = false; while (!readyWithExtensionElement && xtr.hasNext()) { xtr.next(); if (xtr.isCharacters() || XMLStreamReader.CDATA == xtr.getEventType()) { if (StringUtils.isNotEmpty(xtr.getText().trim())) { extensionElement.setElementText(xtr.getText().trim()); } } else if (xtr.isStartElement()) { ExtensionElement childExtensionElement = parseExtensionElement(xtr); extensionElement.addChildElement(childExtensionElement); } else if (xtr.isEndElement() && extensionElement.getName().equalsIgnoreCase(xtr.getLocalName())) { readyWithExtensionElement = true; } } return extensionElement; }
Example 13
Source File: CmmnXmlUtil.java From flowable-engine with Apache License 2.0 | 5 votes |
public static ExtensionElement parseExtensionElement(XMLStreamReader xtr) throws Exception { ExtensionElement extensionElement = new ExtensionElement(); extensionElement.setName(xtr.getLocalName()); if (StringUtils.isNotEmpty(xtr.getNamespaceURI())) { extensionElement.setNamespace(xtr.getNamespaceURI()); } if (StringUtils.isNotEmpty(xtr.getPrefix())) { extensionElement.setNamespacePrefix(xtr.getPrefix()); } for (int i = 0; i < xtr.getAttributeCount(); i++) { ExtensionAttribute extensionAttribute = new ExtensionAttribute(); extensionAttribute.setName(xtr.getAttributeLocalName(i)); extensionAttribute.setValue(xtr.getAttributeValue(i)); if (StringUtils.isNotEmpty(xtr.getAttributeNamespace(i))) { extensionAttribute.setNamespace(xtr.getAttributeNamespace(i)); } if (StringUtils.isNotEmpty(xtr.getAttributePrefix(i))) { extensionAttribute.setNamespacePrefix(xtr.getAttributePrefix(i)); } extensionElement.addAttribute(extensionAttribute); } boolean readyWithExtensionElement = false; while (!readyWithExtensionElement && xtr.hasNext()) { xtr.next(); if (xtr.isCharacters() || XMLStreamReader.CDATA == xtr.getEventType()) { if (StringUtils.isNotEmpty(xtr.getText().trim())) { extensionElement.setElementText(xtr.getText().trim()); } } else if (xtr.isStartElement()) { ExtensionElement childExtensionElement = parseExtensionElement(xtr); extensionElement.addChildElement(childExtensionElement); } else if (xtr.isEndElement() && extensionElement.getName().equalsIgnoreCase(xtr.getLocalName())) { readyWithExtensionElement = true; } } return extensionElement; }
Example 14
Source File: ExtensionElementsXMLConverter.java From flowable-engine with Apache License 2.0 | 5 votes |
protected void readCompletionNeutralRule(XMLStreamReader xtr, ConversionHelper conversionHelper) { if (conversionHelper.getCurrentCmmnElement() instanceof PlanItemControl) { CompletionNeutralRule completionNeutralRule = new CompletionNeutralRule(); completionNeutralRule.setName(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_NAME)); PlanItemControl planItemControl = (PlanItemControl) conversionHelper.getCurrentCmmnElement(); planItemControl.setCompletionNeutralRule(completionNeutralRule); readCommonXmlInfo(completionNeutralRule, xtr); boolean readyWithChildElements = false; try { while (!readyWithChildElements && xtr.hasNext()) { xtr.next(); if (xtr.isStartElement()) { if (CmmnXmlConstants.ELEMENT_CONDITION.equals(xtr.getLocalName())) { xtr.next(); if (xtr.isCharacters()) { completionNeutralRule.setCondition(xtr.getText()); } break; } } else if (xtr.isEndElement()) { if (CmmnXmlConstants.ELEMENT_COMPLETION_NEUTRAL_RULE.equalsIgnoreCase(xtr.getLocalName())) { readyWithChildElements = true; } } } } catch (Exception ex) { LOGGER.error("Error processing CMMN document", ex); throw new XMLException("Error processing CMMN document", ex); } } }
Example 15
Source File: AtomServiceDocumentConsumer.java From cloud-odata-java with Apache License 2.0 | 5 votes |
private AcceptImpl parseAccept(final XMLStreamReader reader) throws XMLStreamException { reader.require(XMLStreamConstants.START_ELEMENT, Edm.NAMESPACE_APP_2007, FormatXml.APP_ACCEPT); CommonAttributesImpl commonAttributes = parseCommonAttribute(reader); String text = ""; while (reader.hasNext() && !(reader.isEndElement() && Edm.NAMESPACE_APP_2007.equals(reader.getNamespaceURI()) && FormatXml.APP_ACCEPT.equals(reader.getLocalName()))) { if (reader.isCharacters()) { text += reader.getText(); } reader.next(); } return new AcceptImpl().setCommonAttributes(commonAttributes).setText(text); }
Example 16
Source File: BaseBpmnXMLConverter.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") protected ExtensionElement parseExtensionElement(XMLStreamReader xtr) throws Exception { ExtensionElement extensionElement = new ExtensionElement(); extensionElement.setName(xtr.getLocalName()); if (StringUtils.isNotEmpty(xtr.getNamespaceURI())) { extensionElement.setNamespace(xtr.getNamespaceURI()); } if (StringUtils.isNotEmpty(xtr.getPrefix())) { extensionElement.setNamespacePrefix(xtr.getPrefix()); } BpmnXMLUtil.addCustomAttributes(xtr, extensionElement, defaultElementAttributes); boolean readyWithExtensionElement = false; while (readyWithExtensionElement == false && xtr.hasNext()) { xtr.next(); if (xtr.isCharacters() || XMLStreamReader.CDATA == xtr.getEventType()) { if (StringUtils.isNotEmpty(xtr.getText().trim())) { extensionElement.setElementText(xtr.getText().trim()); } } else if (xtr.isStartElement()) { ExtensionElement childExtensionElement = parseExtensionElement(xtr); extensionElement.addChildElement(childExtensionElement); } else if (xtr.isEndElement() && extensionElement.getName().equalsIgnoreCase(xtr.getLocalName())) { readyWithExtensionElement = true; } } return extensionElement; }
Example 17
Source File: Library.java From MusicPlayer with MIT License | 4 votes |
public static ObservableList<Playlist> getPlaylists() { if (playlists == null) { playlists = new ArrayList<>(); int id = 0; try { XMLInputFactory factory = XMLInputFactory.newInstance(); factory.setProperty("javax.xml.stream.isCoalescing", true); FileInputStream is = new FileInputStream(new File(Resources.JAR + "library.xml")); XMLStreamReader reader = factory.createXMLStreamReader(is, "UTF-8"); String element; boolean isPlaylist = false; String title = null; ArrayList<Song> songs = new ArrayList<>(); while(reader.hasNext()) { reader.next(); if (reader.isWhiteSpace()) { continue; } else if (reader.isStartElement()) { element = reader.getName().getLocalPart(); // If the element is a play list, reads the element attributes to retrieve // the play list id and title. if (element.equals("playlist")) { isPlaylist = true; id = Integer.parseInt(reader.getAttributeValue(0)); title = reader.getAttributeValue(1); } } else if (reader.isCharacters() && isPlaylist) { // Retrieves the reader value (song ID), gets the song and adds it to the songs list. String value = reader.getText(); songs.add(getSong(Integer.parseInt(value))); } else if (reader.isEndElement() && reader.getName().getLocalPart().equals("playlist")) { // If the play list id, title, and songs have been retrieved, a new play list is created // and the values reset. playlists.add(new Playlist(id, title, songs)); id = -1; title = null; songs = new ArrayList<>(); } else if (reader.isEndElement() && reader.getName().getLocalPart().equals("playlists")) { reader.close(); break; } } reader.close(); } catch (Exception ex) { ex.printStackTrace(); } playlists.sort((x, y) -> { if (x.getId() < y.getId()) { return 1; } else if (x.getId() > y.getId()) { return -1; } else { return 0; } }); playlists.add(new MostPlayedPlaylist(-2)); playlists.add(new RecentlyPlayedPlaylist(-1)); } else { playlists.sort((x, y) -> { if (x.getId() < y.getId()) { return 1; } else if (x.getId() > y.getId()) { return -1; } else { return 0; } }); } return FXCollections.observableArrayList(playlists); }
Example 18
Source File: Base64Type.java From cxf with Apache License 2.0 | 4 votes |
@Override public Object readObject(MessageReader mreader, Context context) throws DatabindingException { XMLStreamReader reader = mreader.getXMLStreamReader(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { reader.next(); while (!reader.isCharacters() && !reader.isEndElement() && !reader.isStartElement()) { reader.next(); } if (reader.isStartElement() && reader.getName().equals(AbstractXOPType.XOP_INCLUDE)) { return optimizedType.readMtoM(mreader, context); } if (reader.isEndElement()) { reader.next(); return new byte[0]; } CharArrayWriter writer = new CharArrayWriter(2048); while (reader.isCharacters()) { writer.write(reader.getTextCharacters(), reader.getTextStart(), reader.getTextLength()); reader.next(); } Base64Utility.decode(writer.toCharArray(), 0, writer.size(), bos); while (reader.getEventType() != XMLStreamConstants.END_ELEMENT) { reader.next(); } // Advance just past the end element reader.next(); return bos.toByteArray(); } catch (Base64Exception | XMLStreamException e) { throw new DatabindingException("Could not parse base64Binary data.", e); } }
Example 19
Source File: DomReader.java From cosmo with Apache License 2.0 | 4 votes |
private static Node readNode(Document d, XMLStreamReader reader) throws XMLStreamException { Node root = null; Node current = null; while (reader.hasNext()) { reader.next(); if (reader.isEndElement()) { if (current.getParentNode() == null) { break; } current = current.getParentNode(); } if (reader.isStartElement()) { Element e = readElement(d, reader); if (root == null) { root = e; } if (current != null) { current.appendChild(e); } current = e; continue; } if (reader.isCharacters()) { CharacterData cd = d.createTextNode(reader.getText()); if (root == null) { return cd; } if (current == null) { return cd; } current.appendChild(cd); continue; } } return root; }
Example 20
Source File: XmlMetadataConsumer.java From olingo-odata2 with Apache License 2.0 | 4 votes |
private AnnotationElement readAnnotationElement(final XMLStreamReader reader) throws XMLStreamException { AnnotationElement aElement = new AnnotationElement(); List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>(); List<AnnotationAttribute> annotationAttributes = new ArrayList<AnnotationAttribute>(); aElement.setName(reader.getLocalName()); String elementNamespace = reader.getNamespaceURI(); if (!edmNamespaces.contains(elementNamespace)) { aElement.setPrefix(reader.getPrefix()); aElement.setNamespace(elementNamespace); } for (int i = 0; i < reader.getAttributeCount(); i++) { AnnotationAttribute annotationAttribute = new AnnotationAttribute(); annotationAttribute.setText(reader.getAttributeValue(i)); annotationAttribute.setName(reader.getAttributeLocalName(i)); annotationAttribute.setPrefix(reader.getAttributePrefix(i)); String namespace = reader.getAttributeNamespace(i); if (namespace != null && !isDefaultNamespace(namespace)) { annotationAttribute.setNamespace(namespace); } annotationAttributes.add(annotationAttribute); } if (!annotationAttributes.isEmpty()) { aElement.setAttributes(annotationAttributes); } boolean justRead = false; if (reader.hasNext()) { reader.next(); justRead = true; } while (justRead && !(reader.isEndElement() && aElement.getName() != null && aElement.getName().equals(reader.getLocalName()))) { justRead = false; if (reader.isStartElement()) { annotationElements.add(readAnnotationElement(reader)); if (reader.hasNext()) { reader.next(); justRead = true; } } else if (reader.isCharacters()) { String elementText = ""; do { justRead = false; elementText = elementText + reader.getText(); if (reader.hasNext()) { reader.next(); justRead = true; } } while (justRead && reader.isCharacters()); aElement.setText(elementText); } } if (!annotationElements.isEmpty()) { aElement.setChildElements(annotationElements); } return aElement; }