为什么 xalan 不会针对格式错误的 XML 抛出 TransformException 错误
在我的单元测试中,我尝试通过将一些格式错误的 xml 发送到 javax.xml.transform.Transformer 调用的 org.apache.xalan.processor.TransformerFactoryImpl 实现来引发 TransformException 错误。
控制台
transform(Source xmlSource,Result outputTarget) throws TransformerException
显示以下消息,但没有引发 TransformerException
file:/filepath/MalformedInput.xml; Line #85; Column #16; XML document structures must start and end within the same entity.
关于为什么它不抛出 TransformerException 或者我如何针对这种情况引发异常有什么想法吗?
我尝试过使用 saxon 并抛出 TransformerException,但我更喜欢使用 xalan
谢谢
In my unit tests I am trying to throw a TransformException error by sending some malformed xml to the org.apache.xalan.processor.TransformerFactoryImpl implementation of javax.xml.transform.Transformer
calling
transform(Source xmlSource,Result outputTarget) throws TransformerException
The console shows the following message, but no TransformerException is thrown
file:/filepath/MalformedInput.xml; Line #85; Column #16; XML document structures must start and end within the same entity.
Any ideas as to why it doesn't throw a TransformerException or how I can raise an Exception for this situation?
I have tried with saxon and a TransformerException is thrown, but i would prefer to use xalan
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在变压器上指定一个 ErrorListener (我相信您在 TransformerFactory 中设置了它)。
you need to specify an ErrorListener on your transformer (i believe you set this in the TransformerFactory).