From: Erik F. <eri...@un...> - 2017-03-28 14:13:18
|
Hi again, I’m afraid the combination of TOKEN_STARTING_TAG and depth is ambiguously. Text tokens and property tokens (e.g. TOKEN_PI_NAME) have the same depth as the element starting tag. To have explicit TOKEN_ENDING_TAG tokens would be really helpful and enhance the usability of VTD-XML a lot. I am fighting half the day for reliable way to tell whether I’m still in a specific element or not. I will make it eventually, but by now I wished I would just have used StAX. I would have finished hours ago if I had. Actually I’m thinking of changing to StAX right now, might be quicker… Best, Erik > On 27 Mar 2017, at 19:39, Nil Ratan Sahoo <nil...@ya...> wrote: > > Hi Erik, > > By default VTDNav.TOKEN_ENDING_TAG is not part of index, you can use VTDNav.TOKEN_STARTING_TAG and depth to determine end of a tag. > > thanks > Nil > > > On Monday, 27 March 2017 8:01 AM, Erik Fäßler <eri...@un...> wrote: > > > Hi Jimmy, > > I am currently building a program using VTD that parses the XML document element-wise. That means that when a TOKEN_START_TAG token is encountered, a specific class is called that processes the current element. For this, the called class iterates over the tokens until it finds the end of the element. I thought I could just wait for a TOKEN_ENDING_TAG token and check if it matches the original TOKEN_START_TAG and the token depth of the start token. However, it seams that absolutely no token is of type TOKEN_ENDING_TAG in the whole document. My code: > > for (int i = vn.getCurrentIndex(); i < vn.getTokenCount(); i++) { > System.out.println(i); > if (vn.getTokenType(i) == VTDNav.TOKEN_ENDING_TAG) > { > System.out.println("Ending token found!"); > System.out.println(vn.toString(i)); > break; > } > } > > > This code never prints out the “Ending token found!” line. It just counts through all tokens up to vn.getTokenCount(). > > Am I doing something wrong? > > Thanks! > > Best regards, > > Erik > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot <http://sdm.link/slashdot>_______________________________________________ > Vtd-xml-users mailing list > Vtd...@li... <mailto:Vtd...@li...> > https://lists.sourceforge.net/lists/listinfo/vtd-xml-users <https://lists.sourceforge.net/lists/listinfo/vtd-xml-users> > > |