use of javax.xml.stream.events.EndElement in project omegat by omegat-org.
the class TMXReader2 method parseTuv.
protected void parseTuv(StartElement element) throws Exception {
ParsedTuv tuv = new ParsedTuv();
currentTu.tuvs.add(tuv);
tuv.changeid = getAttributeValue(element, "changeid");
tuv.changedate = parseISO8601date(getAttributeValue(element, "changedate"));
tuv.creationid = getAttributeValue(element, "creationid");
tuv.creationdate = parseISO8601date(getAttributeValue(element, "creationdate"));
// find 'lang' or 'xml:lang' attribute
for (Iterator<?> it = element.getAttributes(); it.hasNext(); ) {
Attribute a = (Attribute) it.next();
if ("lang".equals(a.getName().getLocalPart())) {
tuv.lang = a.getValue();
break;
}
}
while (true) {
XMLEvent e = xml.nextEvent();
switch(e.getEventType()) {
case XMLEvent.START_ELEMENT:
StartElement eStart = (StartElement) e;
if ("seg".equals(eStart.getName().getLocalPart())) {
if (isOmegaT) {
parseSegOmegaT();
} else if (extTmxLevel2) {
parseSegExtLevel2();
} else {
parseSegExtLevel1();
}
tuv.text = StringUtil.normalizeUnicode(segContent);
}
break;
case XMLEvent.END_ELEMENT:
EndElement eEnd = (EndElement) e;
if ("tuv".equals(eEnd.getName().getLocalPart())) {
return;
}
break;
}
}
}
use of javax.xml.stream.events.EndElement in project omegat by omegat-org.
the class TMXReader2 method parseSegOmegaT.
/**
* OmegaT TMX - just read full text.
*/
protected void parseSegOmegaT() throws Exception {
segContent.setLength(0);
while (true) {
XMLEvent e = xml.nextEvent();
switch(e.getEventType()) {
case XMLEvent.END_ELEMENT:
EndElement eEnd = (EndElement) e;
if ("seg".equals(eEnd.getName().getLocalPart())) {
return;
}
break;
case XMLEvent.CHARACTERS:
Characters c = (Characters) e;
segContent.append(c.getData());
break;
}
}
}
use of javax.xml.stream.events.EndElement in project omegat by omegat-org.
the class TMXReader2 method parseProp.
protected void parseProp(StartElement element) throws Exception {
String propType = getAttributeValue(element, "type");
propContent.setLength(0);
while (true) {
XMLEvent e = xml.nextEvent();
switch(e.getEventType()) {
case XMLEvent.END_ELEMENT:
EndElement eEnd = (EndElement) e;
if ("prop".equals(eEnd.getName().getLocalPart())) {
currentTu.props.add(new TMXProp(propType, propContent.toString()));
return;
}
break;
case XMLEvent.CHARACTERS:
Characters c = (Characters) e;
propContent.append(c.getData());
break;
}
}
}
use of javax.xml.stream.events.EndElement in project omegat by omegat-org.
the class TMXReader2 method parseSegExtLevel1.
/**
* External TMX - level 1. Skip text inside inline tags.
*/
protected void parseSegExtLevel1() throws Exception {
segContent.setLength(0);
int inlineLevel = 0;
while (true) {
XMLEvent e = xml.nextEvent();
switch(e.getEventType()) {
case XMLEvent.START_ELEMENT:
inlineLevel++;
break;
case XMLEvent.END_ELEMENT:
inlineLevel--;
EndElement eEnd = (EndElement) e;
if ("seg".equals(eEnd.getName().getLocalPart())) {
return;
}
break;
case XMLEvent.CHARACTERS:
if (inlineLevel == 0) {
Characters c = (Characters) e;
segContent.append(c.getData());
}
break;
}
}
}
use of javax.xml.stream.events.EndElement in project omegat by omegat-org.
the class TMXReader2 method parseNote.
protected void parseNote(StartElement element) throws Exception {
noteContent.setLength(0);
while (true) {
XMLEvent e = xml.nextEvent();
switch(e.getEventType()) {
case XMLEvent.END_ELEMENT:
EndElement eEnd = (EndElement) e;
if ("note".equals(eEnd.getName().getLocalPart())) {
currentTu.note = noteContent.toString();
return;
}
break;
case XMLEvent.CHARACTERS:
Characters c = (Characters) e;
noteContent.append(c.getData());
break;
}
}
}
Aggregations