jstream.writeQuoted(text.getValue());
jstream.endArray();
break;
case HTML:
if (text.getValue() != null) {
Div div = HtmlHelper.parse(text.getValue());
writeElementValue(div, jstream);
} else {
jstream.writeQuoted("");
}
break;
case XHTML:
if (text.getValueElement() != null) {
writeElementValue(text.getValueElement(), jstream);
} else {
jstream.writeQuoted("");
}
break;
}
jstream.endObject();
}
} else if (element instanceof Content) {
Content content = (Content)element;
Content.Type contenttype = content.getContentType();
if (contenttype.equals(Content.Type.TEXT) && !needToWriteLanguageFields(content)) {
jstream.writeQuoted(content.getValue());
} else {
jstream.startObject();
jstream.writeField("attributes");
jstream.startObject();
switch (content.getContentType()) {
case TEXT:
case HTML:
case XHTML:
jstream.writeField("type", contenttype.name().toLowerCase());
break;
case MEDIA:
case XML:
jstream.writeField("type", content.getMimeType());
}
writeLanguageFields(element, jstream);
if (!isSameAsParentBase(element))
jstream.writeField("xml:base", element.getResolvedBaseUri());
writeLanguageFields(content, jstream);
jstream.writeField("src", content.getResolvedSrc());
jstream.endObject();
jstream.writeField("children");
switch (content.getContentType()) {
case TEXT:
jstream.startArray();
jstream.writeQuoted(content.getValue());
jstream.endArray();
break;
case HTML:
Div div = HtmlHelper.parse(content.getValue());
writeElementValue(div, jstream);
break;
case XHTML:
writeElementValue(content.getValueElement(), jstream);
break;