|
From: Jimmy Z. <cra...@co...> - 2006-08-22 20:14:03
|
----- Original Message -----
From: "Jimmy Zhang" <jz...@xi...>
To: "Walinsky, Frank" <fwa...@ex...>
Cc: <vtd...@li...>
Sent: Tuesday, August 22, 2006 12:57 PM
Subject: Re: push and pop
> It may be a case-specific hack for you...
> AutoPilot internally *remembers* a few variables (string name, depth etc),
> to capture/restore, there may be additional data structure (e.g. a stack)
> needed to store those variables...
>
> but my questions is how you really do anything different from using DOM
> you will still have to instantiate nodeIterators for each levels right?
>
> also vtd...@li... seems to be working now
>
>
> ----- Original Message -----
> From: "Walinsky, Frank" <fwa...@ex...>
> To: "Jimmy Zhang" <jz...@xi...>
> Sent: Tuesday, August 22, 2006 11:46 AM
> Subject: RE: push and pop
>
>
> What might be needed is a capture/restore of the AutoPilot along with
> the currentoffset
>
> -----Original Message-----
> From: Jimmy Zhang [mailto:jz...@xi...] Sent: Tuesday, August 22,
> 2006 11:19 AM
> To: Walinsky, Frank
> Subject: Re: push and pop
>
> I need to think about this...
> ----- Original Message -----
> From: "Walinsky, Frank" <fwa...@ex...>
> To: <jz...@xi...>
> Sent: Tuesday, August 22, 2006 4:13 AM
> Subject: RE: push and pop
>
>
> I will try another approach using just 1 AutoPilot by trying to rework
> my current code.
>
> -----Original Message-----
> From: jz...@xi... [mailto:jz...@xi...] Sent: Monday,
> August 21, 2006 10:18 PM
> To: Walinsky, Frank
> Subject: Re: push and pop
>
> Can you kinda explain why allocating multiple AutoPilots is
> show-stopping??
> because autoPilot allocation is fairly light weight? Maybe VTD-XML can
> custom build something for your case...
>
> Walinsky, Frank writes:
>> Jimmy,
>> I did try 3 different AutoPilots after I sent this and that does work
>> just as you thought it would.
>> It also works without doing any push or pop.
>> My situation has a user generated state which could have an unlimited
>> amount of nesting.
>> This state is processed by some generic code, which is not custom
>> generated but used by all user generated states.
>> This works fine with the DOM product I'm using.
>> I was looking to reduce the memory footprint and do a proof of concept
>> with your app for management.
>> If I can't use the one AutoPilot with push and pop, I'm dead in the
>> water with your app right out of the gate.
>> If you could take a closer look, when you have time, and see if it is
> a
>> bug or just not possible, I would greatly appreciate it.
>> Thx for all your help,
>> Frank
>> ________________________________ From: Jimmy Zhang
>> [mailto:jz...@xi...] Sent: Monday, August 21, 2006 4:13 PM
>> To: Walinsky, Frank; vtd...@li...
>> Subject: Re: push and pop Frank, upon a quick look, I feel you might want
>> to instantiate three
>> autoPilot
>> objects, the first one you set the element name "a," the second set
> the
>> element
>> name "b," and the last one set the element "c." Could
>> Cheers,
>> Jimmy Zhang ----- Original Message -----
>> From: Walinsky, Frank <mailto:fwa...@ex...> To:
>> in...@xi... Sent: Monday, August 21, 2006 12:40 PM
>> Subject: push and pop Jim,
>> I apologize again for using this address but it has become
>> completely frustrrating trying to send to the list.
>> I just tried a handfull of times and had my message returned. I
>> did get one through this morning so I know it does work
>> but when is anybodies guess.
>>
>> Could you please look at this when you have time?
>>
>>
>>
>> Is it possible and if so, is there any sample code somewhere
>> that does the following:
>> (I ask because I haven't found a way or I'm probably using the
>> api incorrectly)
>>
>> I'm trying to use the same AutoPilot object in a 3 level nesting
>> using a VTDNav "push"
>> before entering the next lower level and the VTDNav "pop" before
>> returning to the previous higher level.
>> Neither the "iterate" or an "evalXPath" advance to the next
>> element after the pop.
>>
>> Here's a sample xml I'm using:
>> <?xml version=\"1.0\" encoding=\"UTF-8\"?>
>> <root>
>> <a>
>> <b>
>> <c>this is abc_11</c>
>> <c>this is abc_12</c>
>> <c>this is abc_13</c>
>> <c>this is abc_14</c>
>> </b>
>> <b>
>> <c>this is abc_21</c>
>> <c>this is abc_22</c>
>> <c>this is abc_23</c>
>> <c>this is abc_24</c>
>> </b>
>> </a>
>> <a>
>> <b>
>> <c>this is second abc_31</c>
>> </b>
>> </a>
>> </root>
>>
>>
>> Here's a snippet of my code.
>>
>> vn.toElement(VTDNav.ROOT);
>>
>> ap.selectElement("a");
>> while (ap.iterate()) {
>> System.out.println("--- before push() of \"a\"---");
>> vn.dumpContext();
>> vn.push();
>> System.out.println("a = " + vn.getCurrentIndex());
>>
>> ap.selectElement("b");
>> while (ap.iterate()) {
>> System.out.println("--- before push() of \"b\" ---");
>> vn.dumpContext();
>> vn.push();
>> System.out.println("b = " + vn.getCurrentIndex());
>>
>> ap.selectElement("c");
>> while (ap.iterate()) {
>> System.out.println("c = " + vn.getCurrentIndex());
>> }
>>
>> vn.pop();
>> System.out.println("--- after pop() of \"b\" ---");
>> vn.dumpContext();
>> }
>>
>> vn.pop();
>> System.out.println("--- after pop() of \"a\" ---");
>> vn.dumpContext();
>> }
>>
>
>
>
>
>
>
>
>
|
|
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
|
|
From: Jimmy Z. <cra...@co...> - 2006-08-23 18:54:55
|
RE: push and pop
----- Original Message -----=20
From: Walinsky, Frank=20
To: Jimmy Zhang=20
Sent: Wednesday, August 23, 2006 11:44 AM
Subject: RE: push and pop
-------------------------------------------------------------------------=
-------
From: Jimmy Zhang [mailto:cra...@co...]=20
Sent: Wednesday, August 23, 2006 1:51 PM
To: Walinsky, Frank
Cc: vtd...@us...
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 ??
[Walinsky, Frank] yes, I compile a different XPath and I want to use the =
current iteration element as the new xpath's starting point
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...
[Walinsky, Frank] that's why I thought the push/pop should include any =
and all structures or attributes that can restore to a previous point.=20
Did I misunderstand anything?
[Walinsky, Frank] you nailed it right on the head=20
----- 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
|
|
From: Jimmy Z. <cra...@co...> - 2006-08-24 16:28:56
|
RE: push and pop
----- Original Message -----=20
From: Walinsky, Frank=20
To: Jimmy Zhang=20
Sent: Thursday, August 24, 2006 4:47 AM
Subject: RE: push and pop
Jimmy,
Thanks for confirming that there isn't a bug with push/pop and the =
connection with AutoPilot.
Rather than doing somekind of hack or custom code to get back to the =
original cursor location, I decided to add additional functionality to =
the AutoPilot class.=20
Here's what I did - added a temporary xpath attribute and clones of the =
3 "xpath" methods using the new attribute.=20
Now the original cursor location is not moved and my iteration works as =
I had hoped.
The temporary xpath lets me traverse to any descendent of the current =
node.
What I'm looking at now is how to have the temporary xpath work with an =
absolute path.
You're welcome to have the code and use it as you wish in your project.
If you chose to use it, I only ask that you check it for correctness and =
clean it up if/where necessary.
-------------------------------------------------------------------------=
-------
From: Jimmy Zhang [mailto:cra...@co...]=20
Sent: Wednesday, August 23, 2006 1:51 PM
To: Walinsky, Frank
Cc: vtd...@us...
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
|