1

I have given XML document and some node in it. This node is wrapped by my class and this mentioned class should be 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

Wivani
  • 2,036
  • 22
  • 28
Mateusz Chromiński
  • 2,742
  • 4
  • 28
  • 45
  • this topic is about position in given parent. I would like to achive global position (list of mentioned positions). Solution made in C# is very manual to me - I would like to use dedicated class for this - writing this on my own wouldn't be fancy. – Mateusz Chromiński Aug 17 '11 at 10:15
  • Is this what you're after? http://stackoverflow.com/questions/4746299/generate-get-xpath-from-xml-node-java I don't really understand what you mean by "global position". – Adrian Mouat Aug 17 '11 at 10:32
  • global position means to me full path to given node from xml root – Mateusz Chromiński Aug 17 '11 at 10:50

1 Answers1

0

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:

Cheers, Wim

Wivani
  • 2,036
  • 22
  • 28