javax.xml.stream.events.StartDocument Java Examples

The following examples show how to use javax.xml.stream.events.StartDocument. 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: StaxParserUtilTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void testBypassElementBlockWrongPairing() throws XMLStreamException, ParsingException {
    String xml = "<a><b><c>test</c>"
      + "<d><b>aa</d><d>nestedD</d></d></b></a>";
    XMLEventReader reader = StaxParserUtil.getXMLEventReader(IOUtils.toInputStream(xml, Charset.defaultCharset()));

    assertThat(reader.nextEvent(), instanceOf(StartDocument.class));

    assertStartTag(reader.nextEvent(), "a");
    assertStartTag(reader.nextEvent(), "b");
    assertStartTag(reader.nextEvent(), "c");
    assertCharacters(reader.nextEvent(), is("test"));
    assertEndTag(reader.nextEvent(), "c");

    expectedException.expect(ParsingException.class);
    StaxParserUtil.bypassElementBlock(reader, "d");
}
 
Example #2
Source File: StaxParserUtilTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void testBypassElementBlockNested() throws XMLStreamException, ParsingException {
    String xml = "<a><b><c>test</c>"
      + "<d>aa<d>nestedD</d></d></b></a>";
    XMLEventReader reader = StaxParserUtil.getXMLEventReader(IOUtils.toInputStream(xml, Charset.defaultCharset()));

    assertThat(reader.nextEvent(), instanceOf(StartDocument.class));

    assertStartTag(reader.nextEvent(), "a");
    assertStartTag(reader.nextEvent(), "b");
    assertStartTag(reader.nextEvent(), "c");
    assertCharacters(reader.nextEvent(), is("test"));
    assertEndTag(reader.nextEvent(), "c");

    StaxParserUtil.bypassElementBlock(reader, "d");

    assertEndTag(reader.nextEvent(), "b");
    assertEndTag(reader.nextEvent(), "a");
}
 
Example #3
Source File: StaxParserUtilTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void testBypassElementBlockNestedPrematureEnd() throws XMLStreamException, ParsingException {
    String xml = "<a><b><c>test</c>"
      + "<d>aa<d>nestedD</d></d>";
    XMLEventReader reader = StaxParserUtil.getXMLEventReader(IOUtils.toInputStream(xml, Charset.defaultCharset()));

    assertThat(reader.nextEvent(), instanceOf(StartDocument.class));

    assertStartTag(reader.nextEvent(), "a");
    assertStartTag(reader.nextEvent(), "b");
    assertStartTag(reader.nextEvent(), "c");
    assertCharacters(reader.nextEvent(), is("test"));
    assertEndTag(reader.nextEvent(), "c");

    StaxParserUtil.bypassElementBlock(reader, "d");

    expectedException.expect(XMLStreamException.class);
    reader.nextEvent();
}
 
Example #4
Source File: StaxParserUtilTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void testBypassElementBlockAnon() throws XMLStreamException, ParsingException {
    String xml = "<a><b><c>test</c>"
      + "<d>aa</d></b></a>";
    XMLEventReader reader = StaxParserUtil.getXMLEventReader(IOUtils.toInputStream(xml, Charset.defaultCharset()));

    assertThat(reader.nextEvent(), instanceOf(StartDocument.class));

    assertStartTag(reader.nextEvent(), "a");
    assertStartTag(reader.nextEvent(), "b");
    assertStartTag(reader.nextEvent(), "c");
    assertCharacters(reader.nextEvent(), is("test"));
    assertEndTag(reader.nextEvent(), "c");

    StaxParserUtil.bypassElementBlock(reader);

    assertEndTag(reader.nextEvent(), "b");
    assertEndTag(reader.nextEvent(), "a");
}
 
Example #5
Source File: AnimalRepository.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
public void save(ArrayList<Animal> animals) throws FileNotFoundException, XMLStreamException {
	XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
	XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new FileOutputStream(XML_FILENAME));
	XMLEventFactory eventFactory = XMLEventFactory.newInstance();
	XMLEvent end = eventFactory.createDTD("\n");
	StartDocument startDocument = eventFactory.createStartDocument();
	eventWriter.add(startDocument);
	StartElement configStartElement = eventFactory.createStartElement("", "", "content");
	eventWriter.add(configStartElement);
	eventWriter.add(end);

	for (XML_Parsable animal : animals) {
		StartElement sElement = eventFactory.createStartElement("", "", Constants.XML_TAGS.ANIMAL);
		eventWriter.add(sElement);
		eventWriter.add(end);
		animal.encodeToXml(eventWriter);

		EndElement eElement = eventFactory.createEndElement("", "", Constants.XML_TAGS.ANIMAL);
		eventWriter.add(eElement);
		eventWriter.add(end);
	}

	eventWriter.add(eventFactory.createEndElement("", "", "content"));
	eventWriter.add(eventFactory.createEndDocument());
	eventWriter.close();
}
 
Example #6
Source File: EmployeeRepository.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
public void save(ArrayList<Employee> employees) throws FileNotFoundException, XMLStreamException {
	XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
	XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new FileOutputStream(XML_FILENAME));
	XMLEventFactory eventFactory = XMLEventFactory.newInstance();
	XMLEvent end = eventFactory.createDTD("\n");
	StartDocument startDocument = eventFactory.createStartDocument();
	eventWriter.add(startDocument);
	StartElement configStartElement = eventFactory.createStartElement("", "", "content");
	eventWriter.add(configStartElement);
	eventWriter.add(end);

	for (XML_Parsable employee : employees) {
		StartElement sElement = eventFactory.createStartElement("", "", Constants.XML_TAGS.EMPLOYEE);
		eventWriter.add(sElement);
		eventWriter.add(end);
		employee.encodeToXml(eventWriter);

		EndElement eElement = eventFactory.createEndElement("", "", Constants.XML_TAGS.EMPLOYEE);
		eventWriter.add(eElement);
		eventWriter.add(end);
	}
	eventWriter.add(eventFactory.createEndElement("", "", "content"));
	eventWriter.add(eventFactory.createEndDocument());
	eventWriter.close();
}
 
Example #7
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
public void save(ArrayList<T> entities) throws FileNotFoundException, XMLStreamException {
	XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
	XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new FileOutputStream(this.xmlFilename));
	XMLEventFactory eventFactory = XMLEventFactory.newInstance();
	XMLEvent end = eventFactory.createDTD("\n");
	StartDocument startDocument = eventFactory.createStartDocument();
	eventWriter.add(startDocument);
	StartElement configStartElement = eventFactory.createStartElement("", "", "content");
	eventWriter.add(configStartElement);
	eventWriter.add(end);

	for (XML_Parsable entity : entities) {
		StartElement sElement = eventFactory.createStartElement("", "", this.entityTag);
		eventWriter.add(sElement);
		eventWriter.add(end);
		entity.encodeToXml(eventWriter);

		EndElement eElement = eventFactory.createEndElement("", "", this.entityTag);
		eventWriter.add(eElement);
		eventWriter.add(end);
	}

	eventWriter.add(eventFactory.createEndElement("", "", "content"));
	eventWriter.add(eventFactory.createEndDocument());
	eventWriter.close();
}
 
Example #8
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
public void save(ArrayList<T> entities) throws FileNotFoundException, XMLStreamException {
	XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
	XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new FileOutputStream(this.xmlFilename));
	XMLEventFactory eventFactory = XMLEventFactory.newInstance();
	XMLEvent end = eventFactory.createDTD("\n");
	StartDocument startDocument = eventFactory.createStartDocument();
	eventWriter.add(startDocument);
	StartElement configStartElement = eventFactory.createStartElement("", "", "content");
	eventWriter.add(configStartElement);
	eventWriter.add(end);

	for (XML_Parsable entity : entities) {
		StartElement sElement = eventFactory.createStartElement("", "", this.entityTag);
		eventWriter.add(sElement);
		eventWriter.add(end);
		entity.encodeToXml(eventWriter);

		EndElement eElement = eventFactory.createEndElement("", "", this.entityTag);
		eventWriter.add(eElement);
		eventWriter.add(end);
	}

	eventWriter.add(eventFactory.createEndElement("", "", "content"));
	eventWriter.add(eventFactory.createEndDocument());
	eventWriter.close();
}
 
Example #9
Source File: StaxParserUtilTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void testBypassElementBlock() throws XMLStreamException, ParsingException {
    String xml = "<a><b><c>test</c>"
      + "<d>aa</d></b></a>";
    XMLEventReader reader = StaxParserUtil.getXMLEventReader(IOUtils.toInputStream(xml, Charset.defaultCharset()));

    assertThat(reader.nextEvent(), instanceOf(StartDocument.class));

    assertStartTag(reader.nextEvent(), "a");
    assertStartTag(reader.nextEvent(), "b");
    assertStartTag(reader.nextEvent(), "c");
    assertCharacters(reader.nextEvent(), is("test"));
    assertEndTag(reader.nextEvent(), "c");

    StaxParserUtil.bypassElementBlock(reader, "d");

    assertEndTag(reader.nextEvent(), "b");
    assertEndTag(reader.nextEvent(), "a");
}
 
Example #10
Source File: XMLEventStreamReader.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
@Nullable
public String getVersion() {
	if (this.event.isStartDocument()) {
		return ((StartDocument) this.event).getVersion();
	}
	else {
		return null;
	}
}
 
Example #11
Source File: XMLEventStreamReader.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public boolean isStandalone() {
	if (this.event.isStartDocument()) {
		return ((StartDocument) this.event).isStandalone();
	}
	else {
		throw new IllegalStateException();
	}
}
 
Example #12
Source File: XMLEventStreamReader.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public boolean standaloneSet() {
	if (this.event.isStartDocument()) {
		return ((StartDocument) this.event).standaloneSet();
	}
	else {
		throw new IllegalStateException();
	}
}
 
Example #13
Source File: XMLEventStreamReader.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
@Nullable
public String getVersion() {
	if (this.event.isStartDocument()) {
		return ((StartDocument) this.event).getVersion();
	}
	else {
		return null;
	}
}
 
Example #14
Source File: XMLEventStreamReader.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public boolean isStandalone() {
	if (this.event.isStartDocument()) {
		return ((StartDocument) this.event).isStandalone();
	}
	else {
		throw new IllegalStateException();
	}
}
 
Example #15
Source File: XMLEventStreamReader.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public boolean standaloneSet() {
	if (this.event.isStartDocument()) {
		return ((StartDocument) this.event).standaloneSet();
	}
	else {
		throw new IllegalStateException();
	}
}
 
Example #16
Source File: XMLEventStreamReader.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getVersion() {
	if (this.event.isStartDocument()) {
		return ((StartDocument) this.event).getVersion();
	}
	else {
		return null;
	}
}
 
Example #17
Source File: XMLEventStreamReader.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean isStandalone() {
	if (this.event.isStartDocument()) {
		return ((StartDocument) event).isStandalone();
	}
	else {
		throw new IllegalStateException();
	}
}
 
Example #18
Source File: XMLEventStreamReader.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean standaloneSet() {
	if (this.event.isStartDocument()) {
		return ((StartDocument) this.event).standaloneSet();
	}
	else {
		throw new IllegalStateException();
	}
}
 
Example #19
Source File: Issue53Test.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testEncodingSet() {
    XMLEventFactory f = XMLEventFactory.newInstance();

    try {
        StartDocument sd = f.createStartDocument("UTF-8");
        System.out.println("Encoding: " + sd.getCharacterEncodingScheme());
        System.out.println("Encoding set: " + sd.encodingSet());
        Assert.assertTrue(sd.encodingSet(), "encoding is set, should return true.");
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }

}
 
Example #20
Source File: Issue53Test.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testStandaloneSet() {
    XMLEventFactory f = XMLEventFactory.newInstance();

    try {
        StartDocument sd = f.createStartDocument("UTF-8", "1.0", true);
        System.out.println(sd.isStandalone());
        System.out.println(sd.standaloneSet());
        Assert.assertTrue(sd.standaloneSet(), "standalone is set, should return true.");
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }

}
 
Example #21
Source File: XMLEventStreamReader.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public String getVersion() {
	if (this.event.isStartDocument()) {
		return ((StartDocument) this.event).getVersion();
	}
	else {
		return null;
	}
}
 
Example #22
Source File: XMLEventStreamReader.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isStandalone() {
	if (this.event.isStartDocument()) {
		return ((StartDocument) event).isStandalone();
	}
	else {
		throw new IllegalStateException();
	}
}
 
Example #23
Source File: XMLEventStreamReader.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public boolean standaloneSet() {
	if (this.event.isStartDocument()) {
		return ((StartDocument) this.event).standaloneSet();
	}
	else {
		throw new IllegalStateException();
	}
}
 
Example #24
Source File: StaxXMLWriter.java    From journaldev with MIT License 5 votes vote down vote up
public void writeXML(String fileName, String rootElement, Map<String, String> elementsMap){
        XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance();
        try {
//            XMLEventWriter xmlEventWriter = xmlOutputFactory
//                    .createXMLEventWriter(new FileOutputStream(fileName), "UTF-8");
            //For Debugging - below code to print XML to Console
            XMLEventWriter xmlEventWriter = xmlOutputFactory.createXMLEventWriter(System.out);
            XMLEventFactory eventFactory = XMLEventFactory.newInstance();
            XMLEvent end = eventFactory.createDTD("\n");
            StartDocument startDocument = eventFactory.createStartDocument();
            xmlEventWriter.add(startDocument);
            xmlEventWriter.add(end);
            StartElement configStartElement = eventFactory.createStartElement("",
                "", rootElement);
            xmlEventWriter.add(configStartElement);
            xmlEventWriter.add(end);
            // Write the element nodes
            Set<String> elementNodes = elementsMap.keySet();
            for(String key : elementNodes){
                createNode(xmlEventWriter, key, elementsMap.get(key));
            }
            
            xmlEventWriter.add(eventFactory.createEndElement("", "", rootElement));
            xmlEventWriter.add(end);
            xmlEventWriter.add(eventFactory.createEndDocument());
            xmlEventWriter.close();

        } catch ( XMLStreamException e) {
            e.printStackTrace();
        }
    }
 
Example #25
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public void save(ArrayList<T> entities) throws FileNotFoundException, XMLStreamException {
	XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
	XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new FileOutputStream(this.xmlFilename));
	XMLEventFactory eventFactory = XMLEventFactory.newInstance();
	XMLEvent end = eventFactory.createDTD("\n");
	// Create and write start tag
	StartDocument startDocument = eventFactory.createStartDocument();
	eventWriter.add(startDocument);
	// Create content open tag
	StartElement configStartElement = eventFactory.createStartElement("", "", "content");
	eventWriter.add(configStartElement);
	eventWriter.add(end);

	for (XML_Parsable entity : entities) {
		StartElement sElement = eventFactory.createStartElement("", "", this.entityTag);
		eventWriter.add(sElement);
		eventWriter.add(end);

		entity.encodeToXML(eventWriter);

		EndElement eElement = eventFactory.createEndElement("", "", this.entityTag);
		eventWriter.add(eElement);
		eventWriter.add(end);
	}

	eventWriter.add(eventFactory.createEndElement("", "", "content"));
	eventWriter.add(eventFactory.createEndDocument());
	eventWriter.close();
}
 
Example #26
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public void save(ArrayList<T> entities) throws FileNotFoundException, XMLStreamException {
	XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();

	XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new FileOutputStream(this.xmlFilename));

	XMLEventFactory eventFactory = XMLEventFactory.newInstance();
	XMLEvent end = eventFactory.createDTD("\n");

	StartDocument startDocument = eventFactory.createStartDocument();
	eventWriter.add(startDocument);

	StartElement configStartElement = eventFactory.createStartElement("", "", "content");
	eventWriter.add(configStartElement);
	eventWriter.add(end);

	for (XML_Parsable entitity : entities) {
		StartElement sElement = eventFactory.createStartElement("", "", this.entityTag);
		eventWriter.add(sElement);
		eventWriter.add(end);

		entitity.encodeToXml(eventWriter);

		EndElement eElement = eventFactory.createEndElement("", "", this.entityTag);
		eventWriter.add(eElement);
		eventWriter.add(end);
	}

	eventWriter.add(eventFactory.createEndElement("", "", "content"));
	eventWriter.add(eventFactory.createEndDocument());
	eventWriter.close();
}
 
Example #27
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public void save(ArrayList<T> entities) throws FileNotFoundException, XMLStreamException {

		XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
		// Create XMLEventWriter
		XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new FileOutputStream(this.xmlFilename));
		// Create a EventFactory
		XMLEventFactory eventFactory = XMLEventFactory.newInstance();
		XMLEvent end = eventFactory.createDTD("\n");
		// Create and write Start Tag
		StartDocument startDocument = eventFactory.createStartDocument();
		eventWriter.add(startDocument);
		// Create content open tag
		StartElement configStartElement = eventFactory.createStartElement("", "", "content");
		eventWriter.add(configStartElement);
		eventWriter.add(end);

		for (XML_Parsable entity : entities) {
			StartElement sElement = eventFactory.createStartElement("", "", this.entityTag);
			eventWriter.add(sElement);
			eventWriter.add(end);

			entity.encodeToXml(eventWriter);

			EndElement eElement = eventFactory.createEndElement("", "", this.entityTag);
			eventWriter.add(eElement);
			eventWriter.add(end);

		}
		eventWriter.add(eventFactory.createEndElement("", "", "content"));
		eventWriter.add(eventFactory.createEndDocument());
		eventWriter.close();
	}
 
Example #28
Source File: StaxParserUtilTest.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetDOMElementSameElements() throws XMLStreamException, ParsingException {
    String xml = "<root><test><test><a>b</a></test></test></root>";
    XMLEventReader reader = StaxParserUtil.getXMLEventReader(IOUtils.toInputStream(xml, Charset.defaultCharset()));

    assertThat(reader.nextEvent(), instanceOf(StartDocument.class));

    assertStartTag(reader.nextEvent(), "root");

    Element element = StaxParserUtil.getDOMElement(reader);

    assertThat(element.getNodeName(), is("test"));
    assertThat(element.getChildNodes().getLength(), is(1));

    assertThat(element.getChildNodes().item(0), instanceOf(Element.class));
    Element e = (Element) element.getChildNodes().item(0);
    assertThat(e.getNodeName(), is("test"));

    assertThat(e.getChildNodes().getLength(), is(1));
    assertThat(e.getChildNodes().item(0), instanceOf(Element.class));
    Element e1 = (Element) e.getChildNodes().item(0);
    assertThat(e1.getNodeName(), is("a"));

    assertThat(e1.getChildNodes().getLength(), is(1));
    assertThat(e1.getChildNodes().item(0), instanceOf(Text.class));
    assertThat(((Text) e1.getChildNodes().item(0)).getWholeText(), is("b"));

    assertEndTag(reader.nextEvent(), "root");
    assertThat(reader.nextEvent(), instanceOf(EndDocument.class));

    expectedException.expect(NoSuchElementException.class);
    Assert.fail(String.valueOf(reader.nextEvent()));
}
 
Example #29
Source File: AnimalRepository.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public void save(ArrayList<Animal> animals) throws FileNotFoundException, XMLStreamException {

		XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
		// Create XMLEventWriter
		XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new FileOutputStream(XML_FILENAME));
		// Create a EventFactory
		XMLEventFactory eventFactory = XMLEventFactory.newInstance();
		XMLEvent end = eventFactory.createDTD("\n");
		// Create and write Start Tag
		StartDocument startDocument = eventFactory.createStartDocument();
		eventWriter.add(startDocument);
		// Create content open tag
		StartElement configStartElement = eventFactory.createStartElement("", "", "content");
		eventWriter.add(configStartElement);
		eventWriter.add(end);

		for (XML_Parsable animal : animals) {
			StartElement sElement = eventFactory.createStartElement("", "", Constants.XML_TAGS.ANIMAL);
			eventWriter.add(sElement);
			eventWriter.add(end);

			animal.encodeToXml(eventWriter);

			EndElement eElement = eventFactory.createEndElement("", "", Constants.XML_TAGS.ANIMAL);
			eventWriter.add(eElement);
			eventWriter.add(end);

		}
		eventWriter.add(eventFactory.createEndElement("", "", "content"));
		eventWriter.add(eventFactory.createEndDocument());
		eventWriter.close();
	}
 
Example #30
Source File: EmployeeRepository.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public void save(ArrayList<Employee> employees) throws FileNotFoundException, XMLStreamException {

		XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
		// Create XMLEventWriter
		XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new FileOutputStream(XML_FILENAME));
		// Create a EventFactory
		XMLEventFactory eventFactory = XMLEventFactory.newInstance();
		XMLEvent end = eventFactory.createDTD("\n");
		// Create and write Start Tag
		StartDocument startDocument = eventFactory.createStartDocument();
		eventWriter.add(startDocument);
		// Create content open tag
		StartElement configStartElement = eventFactory.createStartElement("", "", "content");
		eventWriter.add(configStartElement);
		eventWriter.add(end);

		for (XML_Parsable animal : employees) {
			StartElement sElement = eventFactory.createStartElement("", "", Constants.XML_TAGS.EMPLOYEE);
			eventWriter.add(sElement);
			eventWriter.add(end);

			animal.encodeToXml(eventWriter);

			EndElement eElement = eventFactory.createEndElement("", "", Constants.XML_TAGS.EMPLOYEE);
			eventWriter.add(eElement);
			eventWriter.add(end);

		}
		eventWriter.add(eventFactory.createEndElement("", "", "content"));
		eventWriter.add(eventFactory.createEndDocument());
		eventWriter.close();
	}