简体   繁体   English

如何过滤StAX XMLStreamReader

[英]How to filter a StAX XMLStreamReader

I need to hook into an API that receives a StAX XMLStreamReader as the input, and filter the supplied stream (change the value of a certain attribute from true to false). 我需要挂钩一个接收StAX XMLStreamReader作为输入的API,并过滤提供的流(将某个属性的值从true更改为false)。

Looked at StreamReaderDelegate , but with that one I'd have to do a lot of coding to keep track of all access paths to the attribute in question. 看了一下StreamReaderDelegate ,但是我不得不做很多编码来跟踪到该属性的所有访问路径。

Is there a better way? 有没有更好的办法?

Thanks in advance! 提前致谢!

With StAX, you could use the event API instead and utilize the EventReaderDelegate . 使用StAX,您可以改为使用事件API,并利用EventReaderDelegate The amount of code would be roughly the same though. 但是,代码量大致相同。 Using delegates is also the recommended solution, so I'm afraid, there is no significantly better way. 推荐使用代理也是解决方案,因此,恐怕没有更好的方法了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM