java - 当没有特殊字符可见时,为什么我不断收到字符“”是无效的 XML 字符
问题描述
我正在尝试对带有内容的 docx 文件进行语言环境翻译
Name
Name <emp/100>
AccProd < Tool>
Data <Cont:9000000>
ML <mail@gmail.com>
Alto <TL100>
Test<888>
Address < India>
Mode <AUTO>
Mode <manual>
但我没有得到正确的翻译文件,它一直给出这个错误(belo),但它没有说明它发现哪个字符无效。
org.w3c.dom.DOMException: STRING_TOO_LONG:
The resulting string is too long to fit in a DOMString: 'The character ' ' is an invalid XML character'.
Caused by: java.io.IOException: The character ' ' is an invalid XML character
代码 :
DOMImplementationLS ls = (DOMImplementationLS) document.getImplementation();
LSSerializer ser = ls.createLSSerializer();
String xml = ser.writeToString(currentNode); ------> this is where is throws exceptions
currentNode = 待翻译文档中的节点
解决方案
我发现问题是由于多个线程尝试访问文档并对其进行序列化,而另一个线程使用带有不完整 xml 数据的文档。在描述中保持提到的代码在同步块中工作正常,没有奇怪的异常。因为我是新手,所以它很有学习经验。感谢大家花时间审查我的问题。@VGR @hooknc @vanje
推荐阅读
- ios - Cloud Functions 和 DeviceCheck,没有得到 Apple 的响应
- r - R - 文本分析 - 误导性结果
- c# - 为什么 EF Core 中的 DbContext 在事务回滚后返回更改的实体
- javascript - 如何使引导程序无响应?
- php - 调用存储在类变量中的匿名函数
- javascript - 'Readonly<{ children?: ReactNode; 类型上不存在属性 'XYZ' }> & 只读<{}>'
- javascript - 无法在 javascript 中导入模块
- c++ - 为什么我的驱动程序只读取部分字符串?
- angular - 为什么不能在角度 2+ 中加载具有不同参数的相同组件
- mule - Mulesoft :- 强制实现 url 仅监听代理(或)安全实现 url