Java Code Examples for javax.xml.stream.XMLEventFactory#createDTD()
The following examples show how to use
javax.xml.stream.XMLEventFactory#createDTD() .
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: StaxXMLWriter.java From journaldev with MIT License | 6 votes |
private static void createNode(XMLEventWriter eventWriter, String element, String value) throws XMLStreamException { XMLEventFactory xmlEventFactory = XMLEventFactory.newInstance(); XMLEvent end = xmlEventFactory.createDTD("\n"); XMLEvent tab = xmlEventFactory.createDTD("\t"); //Create Start node StartElement sElement = xmlEventFactory.createStartElement("", "", element); eventWriter.add(tab); eventWriter.add(sElement); //Create Content Characters characters = xmlEventFactory.createCharacters(value); eventWriter.add(characters); // Create End node EndElement eElement = xmlEventFactory.createEndElement("", "", element); eventWriter.add(eElement); eventWriter.add(end); }
Example 2
Source File: EntityRepository.java From JavaMainRepo with Apache License 2.0 | 6 votes |
public static void createNode(XMLEventWriter eventWriter, String name, String value) throws XMLStreamException { XMLEventFactory eventFactory = XMLEventFactory.newInstance(); XMLEvent end = eventFactory.createDTD("\n"); XMLEvent tab = eventFactory.createDTD("\t"); StartElement sElement = eventFactory.createStartElement("", "", name); eventWriter.add(tab); eventWriter.add(sElement); Characters characters = eventFactory.createCharacters(value); eventWriter.add(characters); EndElement eElement = eventFactory.createEndElement("", "", name); eventWriter.add(eElement); eventWriter.add(end); }
Example 3
Source File: EntityRepository.java From JavaMainRepo with Apache License 2.0 | 6 votes |
public static void createNode(XMLEventWriter eventWriter, String name, String value) throws XMLStreamException { XMLEventFactory eventFactory = XMLEventFactory.newInstance(); XMLEvent end = eventFactory.createDTD("\n"); XMLEvent tab = eventFactory.createDTD("\t"); // Create Start node StartElement sElement = eventFactory.createStartElement("", "", name); eventWriter.add(tab); eventWriter.add(sElement); // Create Content Characters characters = eventFactory.createCharacters(value); eventWriter.add(characters); // Create End node EndElement eElement = eventFactory.createEndElement("", "", name); eventWriter.add(eElement); eventWriter.add(end); }
Example 4
Source File: EntityRepository.java From JavaMainRepo with Apache License 2.0 | 6 votes |
public static void createNode(XMLEventWriter eventWriter, String name, String value) throws XMLStreamException { XMLEventFactory eventFactory = XMLEventFactory.newInstance(); XMLEvent end = eventFactory.createDTD("\n"); XMLEvent tab = eventFactory.createDTD("\t"); StartElement sElement = eventFactory.createStartElement("", "", name); eventWriter.add(tab); eventWriter.add(sElement); Characters characters = eventFactory.createCharacters(value); eventWriter.add(characters); EndElement eElement = eventFactory.createEndElement("", "", name); eventWriter.add(eElement); eventWriter.add(end); }
Example 5
Source File: EmployeeRepository.java From JavaMainRepo with Apache License 2.0 | 6 votes |
public static void createNode(XMLEventWriter eventWriter, String name, String value) throws XMLStreamException { XMLEventFactory eventFactory = XMLEventFactory.newInstance(); XMLEvent end = eventFactory.createDTD("\n"); XMLEvent tab = eventFactory.createDTD("\t"); // Create Start node StartElement sElement = eventFactory.createStartElement("", "", name); eventWriter.add(tab); eventWriter.add(sElement); // Create Content Characters characters = eventFactory.createCharacters(value); eventWriter.add(characters); // Create End node EndElement eElement = eventFactory.createEndElement("", "", name); eventWriter.add(eElement); eventWriter.add(end); }
Example 6
Source File: EmployeeRepository.java From JavaMainRepo with Apache License 2.0 | 6 votes |
public static void createNode(XMLEventWriter eventWriter, String name, String value) throws XMLStreamException { XMLEventFactory eventFactory = XMLEventFactory.newInstance(); XMLEvent end = eventFactory.createDTD("\n"); XMLEvent tab = eventFactory.createDTD("\t"); StartElement sElement = eventFactory.createStartElement("", "", name); eventWriter.add(tab); eventWriter.add(sElement); Characters characters = eventFactory.createCharacters(value); eventWriter.add(characters); EndElement eElement = eventFactory.createEndElement("", "", name); eventWriter.add(eElement); eventWriter.add(end); }
Example 7
Source File: EntityRepository.java From JavaMainRepo with Apache License 2.0 | 6 votes |
public static void createNode(XMLEventWriter eventWriter, String name, String value) throws XMLStreamException { XMLEventFactory eventFactory = XMLEventFactory.newInstance(); XMLEvent end = eventFactory.createDTD("\n"); XMLEvent tab = eventFactory.createDTD("\t"); // Create Start node StartElement sElement = eventFactory.createStartElement("", "", name); eventWriter.add(tab); eventWriter.add(sElement); // Create Content Characters characters = eventFactory.createCharacters(value); eventWriter.add(characters); // Create End node EndElement eElement = eventFactory.createEndElement("", "", name); eventWriter.add(eElement); eventWriter.add(end); }
Example 8
Source File: EntityRepository.java From JavaMainRepo with Apache License 2.0 | 6 votes |
public static void createNode(XMLEventWriter eventWriter, String name, String value) throws XMLStreamException { XMLEventFactory eventFactory = XMLEventFactory.newInstance(); XMLEvent end = eventFactory.createDTD("\n"); XMLEvent tab = eventFactory.createDTD("\t"); // Create Start node StartElement sElement = eventFactory.createStartElement("", "", name); eventWriter.add(tab); eventWriter.add(sElement); // Create Content Characters characters = eventFactory.createCharacters(value); eventWriter.add(characters); // Create End node EndElement eElement = eventFactory.createEndElement("", "", name); eventWriter.add(eElement); eventWriter.add(end); }
Example 9
Source File: EntityRepository.java From JavaMainRepo with Apache License 2.0 | 6 votes |
public static void createNode(XMLEventWriter eventWriter, String name, String value) throws XMLStreamException { XMLEventFactory eventFactory = XMLEventFactory.newInstance(); XMLEvent end = eventFactory.createDTD("\n"); XMLEvent tab = eventFactory.createDTD("\t"); // Create Start node StartElement sElement = eventFactory.createStartElement("", "", name); eventWriter.add(tab); eventWriter.add(sElement); // Create Content Characters characters = eventFactory.createCharacters(value); eventWriter.add(characters); // Create End node EndElement eElement = eventFactory.createEndElement("", "", name); eventWriter.add(eElement); eventWriter.add(end); }
Example 10
Source File: EntityRepository.java From JavaMainRepo with Apache License 2.0 | 6 votes |
public static void createNode(XMLEventWriter eventWriter, String name, String value) throws XMLStreamException { XMLEventFactory eventFactory = XMLEventFactory.newInstance(); XMLEvent end = eventFactory.createDTD("\n"); XMLEvent tab = eventFactory.createDTD("\t"); // Create Start node StartElement sElement = eventFactory.createStartElement("", "", name); eventWriter.add(tab); eventWriter.add(sElement); // Create Content Characters characters = eventFactory.createCharacters(value); eventWriter.add(characters); // Create End node EndElement eElement = eventFactory.createEndElement("", "", name); eventWriter.add(eElement); eventWriter.add(end); }
Example 11
Source File: EntityRepository.java From JavaMainRepo with Apache License 2.0 | 5 votes |
public void save(ArrayList<T> entities) throws FileNotFoundException, XMLStreamException { XMLOutputFactory outputFactory = XMLOutputFactory.newFactory(); // Create XMLEventWriter XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new FileOutputStream(this.xmlFilename)); // Create an 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 12
Source File: AnimalRepository.java From JavaMainRepo with Apache License 2.0 | 5 votes |
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 13
Source File: AnimalRepository.java From JavaMainRepo with Apache License 2.0 | 5 votes |
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 14
Source File: EntityRepository.java From JavaMainRepo with Apache License 2.0 | 5 votes |
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 15
Source File: EntityRepository.java From JavaMainRepo with Apache License 2.0 | 5 votes |
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 16
Source File: AnimalRepository.java From JavaMainRepo with Apache License 2.0 | 5 votes |
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 17
Source File: EntityRepository.java From JavaMainRepo with Apache License 2.0 | 5 votes |
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 18
Source File: EntityRepository.java From JavaMainRepo with Apache License 2.0 | 5 votes |
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 19
Source File: EntityRepository.java From JavaMainRepo with Apache License 2.0 | 5 votes |
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 20
Source File: EntityRepository.java From JavaMainRepo with Apache License 2.0 | 5 votes |
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 animal : entities) { StartElement sElement = eventFactory.createStartElement("", "", this.entityTag); eventWriter.add(sElement); eventWriter.add(end); animal.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(); }