开发者

Getting XML Node position - XPath?

开发者 https://www.devze.com 2023-03-28 21:15 出处:网络
I have given XML document and some node in it. This node is wrapped by my class and this mentioned class should b开发者_Python百科e serialized and then deserialized (in some workflow). My problem reve

I have given XML document and some node in it. This node is wrapped by my class and this mentioned class should b开发者_Python百科e serialized and then deserialized (in some workflow). My problem reveals because my node implementation (which I have to use) could not be serialized. After deserializing I have to have some reference to serialized node (to be specific - to it's parent).

What I would like to achieve is to save path to my node to some unambiguous object, which could be serialized. Then this object (serialized path) must be unambiguous restored to base Node.

This behaviour places me to think about XPath. XPath object (it's command) can be serialized and can be used to get Node from document. But I don't know any way to save XPath to given Node in context of XML document.

Any help would be appreciated


Could the Externalizable interface help you out here? Or 'add' the writeObject() and readObject() methods to your Serializable-implemented class.

The ideas come from Bruce Eckels Thinking in Java (which should definitely be on your bookshelf) but you can find info on advanced serialization on the net as well:

  • Sun / Oracle article
  • java2s.com article
  • and so on ..

Cheers, Wim

0

精彩评论

暂无评论...
验证码 换一张
取 消