private static void ensureDocumentHasNoError(ThreadContext context, XmlDocument xmlDoc) {
Ruby runtime = context.getRuntime();
RubyArray errors_of_xmlDoc = (RubyArray) xmlDoc.getInstanceVariable("@errors");
if (!errors_of_xmlDoc.isEmpty()) {
throw runtime.newRuntimeError(errors_of_xmlDoc.first().asString().asJavaString());
}
}
@JRubyMethod
public IRubyObject serialize(ThreadContext context, IRubyObject doc) {