use of javax.xml.stream.events.Characters in project uPortal by Jasig.
the class IndentingXMLEventWriter method beforeMarkup.
/**
* Prepare to write markup, by writing a new line and indentation.
*/
protected void beforeMarkup() {
final Set<StackState> state = scopeState.getFirst();
if (!state.contains(StackState.WROTE_DATA) && (depth > 0 || !state.isEmpty())) {
final String indent = getIndent(this.depth, this.indentSize);
final Characters indentEvent = xmlEventFactory.createCharacters(indent);
try {
wrappedWriter.add(indentEvent);
} catch (XMLStreamException e) {
// Ignore exceptions caused by indentation
}
// indentation was written
afterMarkup();
}
}
use of javax.xml.stream.events.Characters 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.Characters 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.Characters 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.Characters 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