You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by Anthony Fryer <ap...@hotmail.com> on 2008/09/18 08:06:43 UTC

best way to uniquely identify a remote XmlObject?

I was wondering if what is the best way to uniquely identify an XmlObject within a document on a remote server?  I need something similar in concept to the signature of a SchemaType which allows me to use SchemaTypeSystem.typeForSignature to retrieve the SchemaType object. 
 
I have up to now been generating the  XPath to the XmlObject to identify it, but am realizing that this breaks easily when peer nodes or parent peer nodes are deleted or inserted, changing the path to the XmlObject.  
 
Are bookmarks what I should use for this?  Do bookmarks persist if a document is reloaded?  Is there some other better way I can do this?
 
Regards,
 
Anthony Fryer
_________________________________________________________________
It's simple! Sell your car for just $40 at CarPoint.com.au
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641&_t=762955845&_r=tig_OCT07&_m=EXT

RE: best way to uniquely identify a remote XmlObject?

Posted by Radu Preotiuc-Pietro <ra...@oracle.com>.
That's an interesting problem. XMLBeans doesn't have anything off the shelf to do this, of course,  but I have been thinking about how best to accomplish this using the tools that XMLBeans does have. I think you have already explored these avenues but let me give you some additional thoughts because I think you need to clarify your requirements.
 
1. If you need a form of identification that survives save/reload, then XPath to the XmlObject is a good solution, but it does assume that while in the "saved" form, the document is not changed.
 
2. If you need a way to "mark" an XmlObject while working with the document in which it is contained, then XmlBookmarks are there for this exact purpose. However, since bookmarks don't have an XML representation, they will be lost after save/reload.
 
3. If you have "write access" to the XmlSchema that backs your documents, then it's simple, you just add an "id" attribute to the type of the XmlObjects that you are interested in tracking - problem solved (something makes me think though that you can't really modify your Schema/saved documents).
 
4. You can combine 1. and 2. as long as all modifications happen while the XmlObject is in-memory. If modifications can happen while the document is in the "saved" form (outside of your control), then I will have to say that the problem is ill-defined: if you had two <foo> elements and a pointer to the second when you saved the document, but when you load you see three <foo>'s, how do you know if another <foo> was inserted in the second position, pushing the <foo> that you're interested in third, or the extra <foo> was inserted in the third position, leaving the one you are interested in second? Maybe saving hashes of the elements that you are interested in would help here, to verify whether they were changed by some other process or not.
 
Hope this helps,
Radu


________________________________

	From: Anthony Fryer [mailto:apfryer@hotmail.com] 
	Sent: Wednesday, September 17, 2008 11:07 PM
	To: dev@xmlbeans.apache.org
	Subject: best way to uniquely identify a remote XmlObject?
	
	
	I was wondering if what is the best way to uniquely identify an XmlObject within a document on a remote server?  I need something similar in concept to the signature of a SchemaType which allows me to use SchemaTypeSystem.typeForSignature to retrieve the SchemaType object. 
	 
	I have up to now been generating the  XPath to the XmlObject to identify it, but am realizing that this breaks easily when peer nodes or parent peer nodes are deleted or inserted, changing the path to the XmlObject.  
	 
	Are bookmarks what I should use for this?  Do bookmarks persist if a document is reloaded?  Is there some other better way I can do this?
	 
	Regards,
	 
	Anthony Fryer
	
	
________________________________

	Sell your car for just $40 at CarPoint.com.au It's simple! <http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641&_t=762955845&_r=tig_OCT07&_m=EXT>