我在 boomi 的 groovy 脚本中遇到上述错误请帮助我!下面是代码。我正在尝试格式化为 xml。数据处理抛出此错误。
import java.util.Properties;
import java.io.InputStream;
import java.io.ByteArrayInputStream;
import com.boomi.execution.ExecutionUtil;
import java.io.BufferedReader;
import java.io.InputStreamReader;
// Retrieve a handle to the Logger
logger = ExecutionUtil.getBaseLogger();
InputStream io = dataContext.getStream(0);
Properties props = dataContext.getProperties(0);
BufferedReader br = new BufferedReader(new InputStreamReader(io));
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
def text = sb.toString();
text = text.replaceAll('<', '')
text = text.replaceAll('>', '')
def xmlStream = new XmlParser().parseText(text);
def data = xmlStream.data;
def result = "<records>"
for (child in data) {
def stringWriter = new StringWriter()
new XmlNodePrinter(new PrintWriter(stringWriter)).print(child)
result = result + stringWriter.toString();
}
result = result + "</records>"
def childIO = new ByteArrayInputStream(result.getBytes());
dataContext.storeStream(childIO, props);