Uploaded image for project: 'Commons JXPath'
  1. Commons JXPath
  2. JXPATH-155

iteratePointers give the wrong pointers

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.3
    • None
    • None
    • jdk 1.5

    Description

      I have a xml structur like these:

       
      <Request>
      	<Tarifierung>
      		<Verkaufsprodukt>
      			<Produkt>
      				<Kondition>
      					<Wert>2</Wert>
      					<Werteinheit>10</Werteinheit>
      				</Kondition>
      				<Kondition>
      					<Wert>3</Wert>
      					<Werteinheit>10</Werteinheit>
      				</Kondition>
      				<Kondition>
      					<Wert>6</Wert>
      					<Werteinheit>10</Werteinheit>
      				</Kondition>
      				<Kondition>
      					<Wert>16</Wert>
      					<Werteinheit>10</Werteinheit>
      				</Kondition>
      			</Produkt>
      		</Verkaufsprodukt>
      	</Tarifierung>
      </Request>
      

      I get an iterator for the "Kondtion" tags:

       
        JXPathContext context = JXPathContext.newContext(in);
        Iterator<Pointer> it_konditionen = (Iterator<Pointer>) context.iteratePointers("/request/tarifierung/verkaufsprodukt[1]/produkt[1]/kondition");
        while (it_konditionen != null && it_konditionen.hasNext()) {
          Pointer p = it_konditionen.next();
          System.out.println(p);
        }
      

      The output to System.out looks like:
      /request/tarifierung/verkaufsprodukt[1]/produkt[1]/kondition[2]
      /request/tarifierung/verkaufsprodukt[1]/produkt[1]/kondition[3]
      /request/tarifierung/verkaufsprodukt[1]/produkt[1]/kondition[4]
      /request/tarifierung/verkaufsprodukt[1]/produkt[1]/kondition[1]
      /request/tarifierung/verkaufsprodukt[1]/produkt[1]/kondition[2]
      /request/tarifierung/verkaufsprodukt[1]/produkt[1]/kondition[3]
      /request/tarifierung/verkaufsprodukt[1]/produkt[1]/kondition[4]

      As we can see it start with [2] (which is not the problem) but it iterates over 2-4 twice! And this IS a problem.

      Very strange is that the call of "it_konditionen.hasNext()" increase the iterator one step.

      Best regards
      Martin Busch

      Attachments

        Activity

          People

            Unassigned Unassigned
            antig Martin Busch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: