From: tony y. <gao...@gm...> - 2006-07-29 15:24:12
|
Hi all: I know the VTD-XML is based on some kind of cursor navigation. But I searched all API docs and can't find how to random access the token I wanted. Just a method: if (vn.toElement(VTDNav.NEXT_CHILD,"*")) { //any action } I think it's not good enough to process my xml. I need another method to achieve this: method(){ ancestorTokenIndex = vn.getCurrentIndex(); } ... foo(){ vn.toIndex(ancestorTokenIndex); int t = vn.getText(); String text = vn.toNormalizedString(t) ; ... } Why I need more arbitrary random access? I just need it. And I think it's easy to implement because VTD-xml design concept, isn't it? -- Kindly Regards Tony =============================== |
From: Jimmy Z. <cra...@co...> - 2006-07-29 17:26:54
|
The navigation has to be based on some criteria (such as specificied in = an XPath expression). VTD navigator uses an array of integers to represent a particular = location in XML, "getCurrentIndex" only returns one those integers in the array... What would be the equivalent function calls in DOM that does what you = described?? ----- Original Message -----=20 From: tony yin=20 To: vtd...@li...=20 Sent: Saturday, July 29, 2006 8:20 AM Subject: [Vtd-xml-users] Need more arbitrary random access Hi all: I know the VTD-XML is based on some kind of cursor navigation. But I = searched all API docs and can't find how to random access the token I = wanted. Just a method: if (vn.toElement(VTDNav.NEXT_CHILD,"*")) {=20 //any action } I think it's not good enough to process my xml. I need another method = to achieve this: method(){ ancestorTokenIndex =3D vn.getCurrentIndex(); } ... foo(){ vn.toIndex(ancestorTokenIndex); int t =3D vn.getText(); String text =3D vn.toNormalizedString(t) ; ... } Why I need more arbitrary random access? I just need it. And I think = it's easy to implement because VTD-xml design concept, isn't it?=20 --=20 Kindly Regards Tony = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=20 -------------------------------------------------------------------------= ----- = -------------------------------------------------------------------------= Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to = share your opinions on IT & business topics through brief surveys -- and earn = cash = http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDEV -------------------------------------------------------------------------= ----- _______________________________________________ Vtd-xml-users mailing list Vtd...@li... https://lists.sourceforge.net/lists/listinfo/vtd-xml-users |
From: tony y. <gao...@gm...> - 2006-07-30 07:15:50
|
Well. For example: <root> <child>AAA</child> <child>BBB</child> <child>CCC</child> ... </root> When processing XML doc in DOM I can reserve every node references in my code and exactly retrieve the 2nd "<child>" node back at anytime I wanted, there is no need to traverse. That's the point I want to be done in VTD-XML Model if I can save the 2nd "<child>" token's index in my code. The necessary situation is, I generate a tree in my UI from an XML and I want mouse click linking to correct node and display information of that node. Sounds reasonable? -- Kindly Regards Tony =============================== |
From: Tatu S. <cow...@ya...> - 2006-07-31 02:43:04
|
--- tony yin <gao...@gm...> wrote: > Well. For example: > <root> > <child>AAA</child> > <child>BBB</child> > <child>CCC</child> > ... > </root> > When processing XML doc in DOM I can reserve every > node references in my > code and exactly retrieve the 2nd "<child>" node > back at anytime I wanted, > there is no need to traverse. That's the point I But VTD-XML uses a simple integer index to refer to all pieces (tokens, similar to nodes, except bit more fine-grained, and bound to physical syntactic components of xml document) of the document. So you'll just need to store these indexes, just like you would Dom Nodes. And that index then needs to given as argument, either directly to methods, or to 'traverse' global pointer (can't remember if VTD-XML had both types of methods). Does this make sense? -+ Tatu +- __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Jimmy Z. <cra...@co...> - 2006-07-31 07:25:24
|
I just want to add to Tatu's comment... People usually navigates XML's metadata to get to the real data, so when you navigate you can just store the index value of text tokens, and you should be able to find a work around that does not require you to store a lot of cursor locations, For your example, why don't u just store the index values for AAA, BBB, CCC??? ----- Original Message ----- From: "Tatu Saloranta" <cow...@ya...> To: <vtd...@li...> Sent: Sunday, July 30, 2006 7:42 PM Subject: Re: [Vtd-xml-users] Need more arbitrary random access > --- tony yin <gao...@gm...> wrote: > >> Well. For example: >> <root> >> <child>AAA</child> >> <child>BBB</child> >> <child>CCC</child> >> ... >> </root> >> When processing XML doc in DOM I can reserve every >> node references in my >> code and exactly retrieve the 2nd "<child>" node >> back at anytime I wanted, >> there is no need to traverse. That's the point I > > But VTD-XML uses a simple integer index to refer to > all pieces (tokens, similar to nodes, except bit more > fine-grained, and bound to physical syntactic > components of xml document) of the document. > So you'll just need to store these indexes, just like > you would Dom Nodes. And that index then needs to > given as argument, either directly to methods, or to > 'traverse' global pointer (can't remember if VTD-XML > had both types of methods). > > Does this make sense? > > -+ Tatu +- > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Vtd-xml-users mailing list > Vtd...@li... > https://lists.sourceforge.net/lists/listinfo/vtd-xml-users > |
From: tony y. <gao...@gm...> - 2006-07-31 13:30:45
|
To Jimmy and Tatu: Yes, I agree on your solution. Please tell me which method I should invoke to send my stored indexs to retrive the values, AAA and BBB and CCC, back? don't tell me I just need " int t = vn.getText(); String text = vn.toNormalizedString(t) ;" method, I know what really happens. -- Kindly Regards Tony =============================== |
From: tony y. <gao...@gm...> - 2006-07-31 14:15:02
|
more comments..... <root> <child> <grandchild1 /> <grandchild2 /> </child> <child> <grandchild1 /> <grandchild2 /> </child> </root> I insist on the VTD-XML have some features to implement. for the reason below: 1. When I store all nodes' index, I need create many objects to reference the indexes, as for the above xml, I need 7 objects to denote the whole tree structure if you can't provide me round-trip cursor movement. And yes, the memory usage will significant small than others even though I create the objects because just 32 bits int spaces and no redundant object created . But it doesn't make any sense against its initial design concept. I mean the VTD-XML project must reconsider the structure to support more flexible cursor-like xml parser. like ResultSet class . 2. Cannot lazy-load the children nodes if xml doc is big enough. As for DOM implementation, yes they can do all things like that. -- Kindly Regards Tony =============================== |
From: Jimmy Z. <cra...@co...> - 2006-07-31 16:49:57
|
Tony, It is important to realize that VTD-XML is not DOM, therefore its = concept of node is different from DOM's. In DOM , you can save pointers and later refer to it, VTD-XML, on = the other hand, has a single=20 cursor that you can navigate to different part of the XML tree... so the = concept is different, and will lead to different coding style, and way of thinking about processing XML... = whatever you want to do in DOM should=20 be achievable using VTD-XML as well... concerning the provided example, what is the motivation to store all = cursor locations?=20 Jimmy zhang ----- Original Message -----=20 From: tony yin=20 To: vtd...@li...=20 Sent: Monday, July 31, 2006 7:14 AM Subject: Re: [Vtd-xml-users] Need more arbitrary random access more comments..... <root> <child> <grandchild1 /> <grandchild2 /> </child> <child> <grandchild1 /> <grandchild2 /> </child> </root> I insist on the VTD-XML have some features to implement. for the = reason below: 1. When I store all nodes' index, I need create many objects to = reference the indexes, as for the above xml, I need 7 objects to denote = the whole tree structure if you can't provide me round-trip cursor = movement. And yes, the memory usage will significant small than others = even though I create the objects because just 32 bits int spaces and no = redundant object created . But it doesn't make any sense against its = initial design concept.=20 I mean the VTD-XML project must reconsider the structure to support = more flexible cursor-like xml parser. like ResultSet class . 2. Cannot lazy-load the children nodes if xml doc is big enough. As for DOM implementation, yes they can do all things like that.=20 --=20 Kindly Regards Tony = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=20 -------------------------------------------------------------------------= ----- = -------------------------------------------------------------------------= Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to = share your opinions on IT & business topics through brief surveys -- and earn = cash = http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDEV -------------------------------------------------------------------------= ----- _______________________________________________ Vtd-xml-users mailing list Vtd...@li... https://lists.sourceforge.net/lists/listinfo/vtd-xml-users |
From: tony y. <gao...@gm...> - 2006-08-02 08:42:25
|
So, It's hard to achieve "vn.toElementByIndex(index)", right? I am continuing need for features like that! |
From: Jimmy Z. <cra...@co...> - 2006-08-02 19:14:06
|
A few reasons this"elementByIndex(index) is not a good thing to do 1. While an element is identified by its index, an index doesn't always = map to an element 2. VTD-XML's internal node presentation is more than just an index = value, so supply an index and expect VTD-XML's navigator to jump to it is inadequate... I think that it boils to the fact that VTD-XML is not DOM, so the code = style will be different, this is a subtle difference that requires developers to rethink their XML processing = tasks... ----- Original Message -----=20 From: tony yin=20 To: Vtd...@li...=20 Sent: Wednesday, August 02, 2006 1:42 AM Subject: Re: [Vtd-xml-users] Need more arbitrary random access So, It's hard to achieve "vn.toElementByIndex(index)", right? I am continuing need for features like that! -------------------------------------------------------------------------= ----- = -------------------------------------------------------------------------= Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to = share your opinions on IT & business topics through brief surveys -- and earn = cash = http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDEV -------------------------------------------------------------------------= ----- _______________________________________________ Vtd-xml-users mailing list Vtd...@li... https://lists.sourceforge.net/lists/listinfo/vtd-xml-users |
From: Jimmy Z. <cra...@co...> - 2006-07-30 07:33:58
|
There is a global stack that you can access. Since it is a stack it is = first-in last out, so you can push in a node then pop it back out... vn.push(); // save the location ....// do what ever you want, such as navigation vn.pop(); // instantly restore cursor to the saved location... Have you tried the demo on the sourceforge web page? it seems to do what = you have described ... ----- Original Message -----=20 From: tony yin=20 To: vtd...@li...=20 Cc: vtd...@li...=20 Sent: Sunday, July 30, 2006 12:15 AM Subject: Re: [Vtd-xml-users] Need more arbitrary random access Well. For example: <root> <child>AAA</child> <child>BBB</child> <child>CCC</child> ... </root> When processing XML doc in DOM I can reserve every node references in = my code and exactly retrieve the 2nd "<child>" node back at anytime I = wanted, there is no need to traverse. That's the point I want to be done = in VTD-XML Model if I can save the 2nd "<child>" token's index in my = code. The necessary situation is, I generate a tree in my UI from an XML = and I want mouse click linking to correct node and display information = of that node.=20 Sounds reasonable? --=20 Kindly Regards Tony = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=20 -------------------------------------------------------------------------= ----- = -------------------------------------------------------------------------= Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to = share your opinions on IT & business topics through brief surveys -- and earn = cash = http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDEV -------------------------------------------------------------------------= ----- _______________________________________________ Vtd-xml-users mailing list Vtd...@li... https://lists.sourceforge.net/lists/listinfo/vtd-xml-users |