本文整理汇总了Java中javax.xml.stream.events.EndElement类的典型用法代码示例。如果您正苦于以下问题:Java EndElement类的具体用法?Java EndElement怎么用?Java EndElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EndElement类属于javax.xml.stream.events包,在下文中一共展示了EndElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleEndElement
import javax.xml.stream.events.EndElement; //导入依赖的package包/类
private void handleEndElement(EndElement event) throws SAXException {
if(!seenText && predictor.expectText()) {
visitor.text("");
}
// fire endElement
QName qName = event.getName();
tagName.uri = fixNull(qName.getNamespaceURI());
tagName.local = qName.getLocalPart();
visitor.endElement(tagName);
// end namespace bindings
for( Iterator<Namespace> i = event.getNamespaces(); i.hasNext();) {
String prefix = fixNull(i.next().getPrefix()); // be defensive
visitor.endPrefixMapping(prefix);
}
seenText = false;
}
示例2: handleEndElement
import javax.xml.stream.events.EndElement; //导入依赖的package包/类
private void handleEndElement(EndElement endElement) throws SAXException {
if (getContentHandler() != null) {
QName qName = endElement.getName();
if (hasNamespacesFeature()) {
getContentHandler().endElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName));
for (Iterator i = endElement.getNamespaces(); i.hasNext();) {
Namespace namespace = (Namespace) i.next();
endPrefixMapping(namespace.getPrefix());
}
}
else {
getContentHandler().endElement("", "", toQualifiedName(qName));
}
}
}
示例3: createNode
import javax.xml.stream.events.EndElement; //导入依赖的package包/类
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);
}
示例4: parseHeaderProp
import javax.xml.stream.events.EndElement; //导入依赖的package包/类
/**
* Parse prop elements in Header.
*
* @param element XML element.
* @throws Exception when error happend.
*/
private void parseHeaderProp(StartElement element) throws Exception {
String propType = getAttributeValue(element, "type");
StringBuilder headerPropContent = new StringBuilder();
while (true) {
XMLEvent evt = xml.nextEvent();
switch (evt.getEventType()) {
case XMLEvent.END_ELEMENT:
EndElement eleEnd = (EndElement) evt;
if ("prop".equals(eleEnd.getName().getLocalPart())) {
header.props.put(propType, headerPropContent.toString());
return;
}
break;
case XMLEvent.CHARACTERS:
Characters ch = (Characters) evt;
headerPropContent.append(ch.getData());
break;
default:
break;
}
}
}
示例5: parseHeaderNote
import javax.xml.stream.events.EndElement; //导入依赖的package包/类
private void parseHeaderNote(StartElement element) throws Exception {
noteContent.setLength(0);
while (true) {
XMLEvent evt = xml.nextEvent();
switch (evt.getEventType()) {
case XMLEvent.END_ELEMENT:
EndElement eleEnd = (EndElement) evt;
if ("note".equals(eleEnd.getName().getLocalPart())) {
header.note = noteContent.toString();
return;
}
break;
case XMLEvent.CHARACTERS:
Characters ch = (Characters) evt;
noteContent.append(ch.getData());
break;
default:
break;
}
}
}
示例6: createNode
import javax.xml.stream.events.EndElement; //导入依赖的package包/类
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);
}
示例7: parseTuNote
import javax.xml.stream.events.EndElement; //导入依赖的package包/类
private void parseTuNote(StartElement element) throws Exception {
noteContent.setLength(0);
while (true) {
XMLEvent evt = xml.nextEvent();
switch (evt.getEventType()) {
case XMLEvent.END_ELEMENT:
EndElement eleEnd = (EndElement) evt;
if ("note".equals(eleEnd.getName().getLocalPart())) {
currentTu.note = noteContent.toString();
return;
}
break;
case XMLEvent.CHARACTERS:
Characters ch = (Characters) evt;
noteContent.append(ch.getData());
break;
default:
break;
}
}
}
示例8: parseSegOmegaT
import javax.xml.stream.events.EndElement; //导入依赖的package包/类
/**
* OmegaT TMX - just read full text.
*/
private void parseSegOmegaT() throws Exception {
segContent.setLength(0);
while (true) {
XMLEvent evt = xml.nextEvent();
switch (evt.getEventType()) {
case XMLEvent.END_ELEMENT:
EndElement eleEnd = (EndElement) evt;
if ("seg".equals(eleEnd.getName().getLocalPart())) {
return;
}
break;
case XMLEvent.CHARACTERS:
Characters ch = (Characters) evt;
segContent.append(ch.getData());
break;
default:
break;
}
}
}
示例9: createNode
import javax.xml.stream.events.EndElement; //导入依赖的package包/类
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);
}
示例10: createNode
import javax.xml.stream.events.EndElement; //导入依赖的package包/类
/**
*
* @param eventWriter
* .
* @param name
* The name.
* @param value
* The value.
* @throws XMLStreamException
* .
*/
public static void createNode(final XMLEventWriter eventWriter, final String name, final 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);
}
示例11: createNode
import javax.xml.stream.events.EndElement; //导入依赖的package包/类
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);
}
示例12: createNode
import javax.xml.stream.events.EndElement; //导入依赖的package包/类
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);
}
示例13: save
import javax.xml.stream.events.EndElement; //导入依赖的package包/类
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();
}
示例14: save
import javax.xml.stream.events.EndElement; //导入依赖的package包/类
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();
}
示例15: save
import javax.xml.stream.events.EndElement; //导入依赖的package包/类
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();
}