protected void printContent(final XMLStreamWriter out,
final FormatStack fstack, final NamespaceStack nstack,
final Walker walker) throws XMLStreamException {
while (walker.hasNext()) {
final Content content = walker.next();
if (content == null) {
if (walker.isCDATA()) {
printCDATA(out, fstack, new CDATA(walker.text()));
} else {
printText(out, fstack, new Text(walker.text()));
}
} else {
switch (content.getCType()) {
case CDATA:
printCDATA(out, fstack, (CDATA) content);
break;
case Comment:
printComment(out, fstack, (Comment) content);
break;
case Element:
printElement(out, fstack, nstack, (Element) content);
break;
case EntityRef:
printEntityRef(out, fstack, (EntityRef) content);
break;
case ProcessingInstruction:
printProcessingInstruction(out, fstack,
(ProcessingInstruction) content);
break;
case Text:
printText(out, fstack, (Text) content);
break;
case DocType:
printDocType(out, fstack, (DocType) content);
break;
default:
throw new IllegalStateException(
"Unexpected Content " + content.getCType());
}
}
}