From: Jimmy Z. <cra...@co...> - 2006-08-23 17:59:11
|
RE: push and pop ----- Original Message -----=20 From: Jimmy Zhang=20 To: Walinsky, Frank=20 Cc: vtd...@us...=20 Sent: Wednesday, August 23, 2006 10:51 AM Subject: Re: push and pop It is great that you brought up this interesting discussion, we = certainly want to know how you use VTD-XML and how it can be made better... When you say "Xpath with the same AutoPilot to somewhere else and print = it's content." do you mean you use AutoPilot to compile a different XPath expression ?? If that is the case, if you have already lost the Xpath expression = previously compiled, and even you got back to the original position using pop(), the old xpath = expression is completely gone... Did I misunderstand anything? ----- Original Message -----=20 From: Walinsky, Frank=20 To: Jimmy Zhang=20 Sent: Wednesday, August 23, 2006 5:36 AM Subject: RE: push and pop It would be easier to have you give me a code snippet using your = product, since that's what I'm trying to use.=20 If you could provide a code snippet that shows the following = (highlighted in red and a direct copy from your website):=20 Cursor-based hierarchical view: In this view, one navigates the cursor = across the hierarchy. However, one should notice that this hierarchy is = for elements only; in other words, in our processing, we only consider = elements as part of the hierarchy, and treats text node, CDATA and = attributes as belongings of an element. Also there is one and only one = global cursor available. Duplicate of this cursor is disallowed. To = record the position of a cursor, one can either save the VTD index value = or push the cursor value into a global stack, and later pop it back. The = following code snippet navigates a very simple XML document and prints = out value of interest. =20 I need to see a working code snippet that does both ways that are = described above in red highlight.=20 Here is a simple senerio using 1 AutoPilot that would be of most use:=20 :=20 Setup, with an xpath, an iteration that will have more than one = result.=20 Do the "evalXPath" iteration.=20 Save the current location as described above in red.=20 Xpath with the same AutoPilot to somewhere else and print it's = content.=20 Reset back to the location saved previously.=20 Go back to the "evalXPath" iteration step above and get the next = iteration=20 Again - thank you for your patience and all the help you have been = giving me.=20 Frank=20 -----Original Message-----=20 From: Jimmy Zhang [mailto:cra...@co...]=20 Sent: Tuesday, August 22, 2006 5:34 PM=20 To: Walinsky, Frank=20 Cc: vtd...@li...=20 Subject: Re: push and pop=20 Yes, this is indeed how Autopilot is implemented, one xpath expression = per autoPilot object is the intended user, and nodeIteration can be = thought of as an xpath expression... I think it may be easier if there is code on how DOM would work, and I = can offer you suggestions/workarounds in VTD-XML code... If you try DOM's node iterator, it is quite similar to VTD-XML's = autoPilot=20 ----- Original Message -----=20 From: "Walinsky, Frank" <fwa...@ex...>=20 To: "Jimmy Zhang" <jz...@xi...>=20 Sent: Tuesday, August 22, 2006 1:58 PM=20 Subject: RE: push and pop=20 Using the xml doc from below:=20 I'm iterating over the "a" element and then the "b" element.=20 For each "b" element, the user wants to use one of its children(one of = the "c" elements). I have the "c" element name in a variable ( in = actual=20 practice the "c" element names are unique) and I do an xpath using the = AutoPilot and this variable to get the correct child. Then I do=20 something with the "c" element content. Now I want to go back to the = top=20 of the iteration and get the next "b" element. This is where the=20 AutoPilot thinks there are no more "b" elements when in fact there is=20 one more "b" element in the first "a" element.=20 -----Original Message-----=20 From: Jimmy Zhang [mailto:jz...@xi...]=20 Sent: Tuesday, August 22, 2006 3:57 PM=20 To: Walinsky, Frank=20 Cc: vtd...@li...=20 Subject: Re: push and pop=20 It may be a case-specific hack for you...=20 AutoPilot internally *remembers* a few variables (string name, depth=20 etc), to capture/restore, there may be additional data structure (e.g. = a=20 stack) needed to store those variables...=20 but my questions is how you really do anything different from using = DOM=20 you will still have to instantiate nodeIterators for each levels = right?=20 also vtd...@li... seems to be working now=20 ----- Original Message -----=20 From: "Walinsky, Frank" <fwa...@ex...>=20 To: "Jimmy Zhang" <jz...@xi...>=20 Sent: Tuesday, August 22, 2006 11:46 AM=20 Subject: RE: push and pop=20 What might be needed is a capture/restore of the AutoPilot along with=20 the currentoffset=20 -----Original Message-----=20 From: Jimmy Zhang [mailto:jz...@xi...]=20 Sent: Tuesday, August 22, 2006 11:19 AM=20 To: Walinsky, Frank=20 Subject: Re: push and pop=20 I need to think about this...=20 ----- Original Message -----=20 From: "Walinsky, Frank" <fwa...@ex...>=20 To: <jz...@xi...>=20 Sent: Tuesday, August 22, 2006 4:13 AM=20 Subject: RE: push and pop=20 I will try another approach using just 1 AutoPilot by trying to rework = my current code.=20 -----Original Message-----=20 From: jz...@xi... [mailto:jz...@xi...]=20 Sent: Monday, August 21, 2006 10:18 PM=20 To: Walinsky, Frank=20 Subject: Re: push and pop=20 Can you kinda explain why allocating multiple AutoPilots is=20 show-stopping??=20 because autoPilot allocation is fairly light weight? Maybe VTD-XML can = custom build something for your case...=20 Walinsky, Frank writes:=20 > Jimmy,=20 > I did try 3 different AutoPilots after I sent this and that does = work=20 > just as you thought it would.=20 > It also works without doing any push or pop.=20 > My situation has a user generated state which could have an = unlimited=20 > amount of nesting.=20 > This state is processed by some generic code, which is not custom=20 > generated but used by all user generated states.=20 > This works fine with the DOM product I'm using.=20 > I was looking to reduce the memory footprint and do a proof of = concept=20 > with your app for management.=20 > If I can't use the one AutoPilot with push and pop, I'm dead in the=20 > water with your app right out of the gate.=20 > If you could take a closer look, when you have time, and see if it = is=20 a=20 > bug or just not possible, I would greatly appreciate it.=20 > Thx for all your help,=20 > Frank=20 >=20 >=20 > ________________________________=20 >=20 > From: Jimmy Zhang [mailto:jz...@xi...]=20 > Sent: Monday, August 21, 2006 4:13 PM=20 > To: Walinsky, Frank; vtd...@li...=20 > Subject: Re: push and pop=20 >=20 >=20 > Frank, upon a quick look, I feel you might want to instantiate three = > autoPilot=20 > objects, the first one you set the element name "a," the second set=20 the=20 > element=20 > name "b," and the last one set the element "c." Could=20 > Cheers,=20 > Jimmy Zhang=20 >=20 > ----- Original Message -----=20 > From: Walinsky, Frank <mailto:fwa...@ex...>=20 > To: in...@xi...=20 > Sent: Monday, August 21, 2006 12:40 PM=20 > Subject: push and pop=20 >=20 > Jim,=20 > I apologize again for using this address but it has become=20 > completely frustrrating trying to send to the list.=20 > I just tried a handfull of times and had my message returned. I=20 > did get one through this morning so I know it does work=20 > but when is anybodies guess.=20 >=20 > Could you please look at this when you have time?=20 >=20 >=20 >=20 > Is it possible and if so, is there any sample code somewhere=20 > that does the following:=20 > (I ask because I haven't found a way or I'm probably using the=20 > api incorrectly)=20 >=20 > I'm trying to use the same AutoPilot object in a 3 level nesting=20 > using a VTDNav "push"=20 > before entering the next lower level and the VTDNav "pop" before=20 > returning to the previous higher level.=20 > Neither the "iterate" or an "evalXPath" advance to the next=20 > element after the pop.=20 >=20 > Here's a sample xml I'm using:=20 > <?xml version=3D\"1.0\" encoding=3D\"UTF-8\"?>=20 > <root>=20 > <a>=20 > <b>=20 > <c>this is abc_11</c>=20 > <c>this is abc_12</c>=20 > <c>this is abc_13</c>=20 > <c>this is abc_14</c>=20 > </b>=20 > <b>=20 > <c>this is abc_21</c>=20 > <c>this is abc_22</c>=20 > <c>this is abc_23</c>=20 > <c>this is abc_24</c>=20 > </b>=20 > </a>=20 > <a>=20 > <b>=20 > <c>this is second abc_31</c>=20 > </b>=20 > </a>=20 > </root>=20 >=20 >=20 > Here's a snippet of my code.=20 >=20 > vn.toElement(VTDNav.ROOT);=20 >=20 > ap.selectElement("a");=20 > while (ap.iterate()) {=20 > System.out.println("--- before push() of \"a\"---");=20 > vn.dumpContext();=20 > vn.push();=20 > System.out.println("a =3D " + vn.getCurrentIndex());=20 >=20 > ap.selectElement("b");=20 > while (ap.iterate()) {=20 > System.out.println("--- before push() of \"b\" ---");=20 > vn.dumpContext();=20 > vn.push();=20 > System.out.println("b =3D " + vn.getCurrentIndex());=20 >=20 > ap.selectElement("c");=20 > while (ap.iterate()) {=20 > System.out.println("c =3D " + vn.getCurrentIndex());=20 > }=20 >=20 > vn.pop();=20 > System.out.println("--- after pop() of \"b\" ---");=20 > vn.dumpContext();=20 > }=20 >=20 > vn.pop();=20 > System.out.println("--- after pop() of \"a\" ---");=20 > vn.dumpContext();=20 > }=20 >=20 >=20 >=20 >=20 >=20 >=20 >=20 |