[prev in list] [next in list] [prev in thread] [next in thread]
List: xmlbeans-dev
Subject: RE: best way to uniquely identify a remote XmlObject?
From: "Radu Preotiuc-Pietro" <radu.preotiuc-pietro () oracle ! com>
Date: 2008-09-25 19:37:33
Message-ID: 20080925123733953.00000003368 () RADUP02
[Download RAW message or body]
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%2Fcg \
i%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641&_t=762955845&_r=tig_OCT07&_m=EXT> \
[Attachment #3 (text/html)]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<STYLE>.hmmessage P {
PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; \
PADDING-TOP: 0px }
BODY.hmmessage {
FONT-SIZE: 10pt; FONT-FAMILY: Tahoma
}
</STYLE>
<META content="MSHTML 6.00.2900.3395" name=GENERATOR></HEAD>
<BODY class=hmmessage>
<DIV dir=ltr align=left><SPAN class=343365718-25092008><FONT face=Arial
color=#0000ff>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.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=343365718-25092008><FONT face=Arial
color=#0000ff></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=343365718-25092008><FONT face=Arial
color=#0000ff>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.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=343365718-25092008><FONT face=Arial
color=#0000ff></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=343365718-25092008><FONT face=Arial
color=#0000ff>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.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=343365718-25092008><FONT face=Arial
color=#0000ff></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=343365718-25092008><FONT face=Arial
color=#0000ff>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).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=343365718-25092008><FONT face=Arial
color=#0000ff></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=343365718-25092008><FONT face=Arial
color=#0000ff>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.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=343365718-25092008><FONT face=Arial
color=#0000ff></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=343365718-25092008><FONT face=Arial
color=#0000ff>Hope this helps,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=343365718-25092008><FONT face=Arial
color=#0000ff>Radu</FONT></SPAN></DIV><BR>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; \
MARGIN-RIGHT: 0px"> <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma><B>From:</B> Anthony Fryer [mailto:apfryer@hotmail.com]
<BR><B>Sent:</B> Wednesday, September 17, 2008 11:07 PM<BR><B>To:</B>
dev@xmlbeans.apache.org<BR><B>Subject:</B> best way to uniquely identify a
remote XmlObject?<BR></FONT><BR></DIV>
<DIV></DIV>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. <BR> <BR>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. <BR> <BR>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?<BR> <BR>Regards,<BR> <BR>Anthony Fryer<BR><BR>
<HR>
Sell your car for just $40 at CarPoint.com.au <A
href="http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ec \
om%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641&_t=762955845&_r=tig_OCT07&_m=EXT" \
target=_new>It's simple! </A></BLOCKQUOTE></BODY></HTML>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic