1653 * </pre>
1654 * <p>
1655 * <strong>Note:</strong> This method uses the fElementQName variable.
1656 * The contents of this variable will be destroyed. The caller should
1657 * copy the needed information out of this variable before calling
1658 * this method.
1659 *
1660 * @return The element depth.
1661 */
1662 protected int scanEndElement() throws IOException, XNIException {
1663 if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +">>> scanEndElement()");
1664
1665 // pop context
1666 QName endElementName = fElementStack.popElement();
1667
1668 String rawname = endElementName.rawname;
1669 if(DEBUG)System.out.println("endElementName = " + endElementName.toString());
1670 // Take advantage of the fact that next string _should_ be "fElementQName.rawName",
1671 //In scanners most of the time is consumed on checks done for XML characters, we can
1672 // optimize on it and avoid the checks done for endElement,
1673 //we will also avoid symbol table lookup - neeraj.bajaj@sun.com
1674
1675 // this should work both for namespace processing true or false...
1676
1677 //REVISIT: if the string is not the same as expected.. we need to do better error handling..
1678 //We can skip this for now... In any case if the string doesn't match -- document is not well formed.
1679
1680 if (!fEntityScanner.skipString(endElementName.rawname)) {
1681 reportFatalError("ETagRequired", new Object[]{rawname});
1682 }
1683
1684 // end
1685 fEntityScanner.skipSpaces();
1686 if (!fEntityScanner.skipChar('>', NameType.ELEMENTEND)) {
1687 reportFatalError("ETagUnterminated",
1688 new Object[]{rawname});
1689 }
1690 fMarkupDepth--;
1691
1692 //we have increased the depth for two markup "<" characters
1693 fMarkupDepth--;
2444 for( int i = 0 ; i < fDepth ; i++){
2445 System.out.println("fElements[" + i + "]" + " = " + fElements[i].rawname);
2446 }
2447 }
2448 }
2449
2450 /** Clears the stack without throwing away existing QName objects. */
2451 public void clear() {
2452 fDepth = 0;
2453 fLastDepth = 0;
2454 fCount = 0 ;
2455 fPosition = fMark = 1;
2456
2457 } // clear()
2458
2459 /**
2460 * This function is as a result of optimization done for endElement --
2461 * we dont need to set the value for every end element encouterd.
2462 * For Well formedness checks we can have the same QName object that was pushed.
2463 * the values will be set only if application need to know about the endElement
2464 * -- neeraj.bajaj@sun.com
2465 */
2466
2467 public QName getLastPoppedElement(){
2468 return fElements[fDepth];
2469 }
2470 } // class ElementStack
2471
2472 /**
2473 * Drives the parser to the next state/event on the input. Parser is guaranteed
2474 * to stop at the next state/event.
2475 *
2476 * Internally XML document is divided into several states. Each state represents
2477 * a sections of XML document. When this functions returns normally, it has read
2478 * the section of XML document and returns the state corresponding to section of
2479 * document which has been read. For optimizations, a particular driver
2480 * can read ahead of the section of document (state returned) just read and
2481 * can maintain a different internal state.
2482 *
2483 *
2484 * @author Neeraj Bajaj, Sun Microsystems
|
1653 * </pre>
1654 * <p>
1655 * <strong>Note:</strong> This method uses the fElementQName variable.
1656 * The contents of this variable will be destroyed. The caller should
1657 * copy the needed information out of this variable before calling
1658 * this method.
1659 *
1660 * @return The element depth.
1661 */
1662 protected int scanEndElement() throws IOException, XNIException {
1663 if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +">>> scanEndElement()");
1664
1665 // pop context
1666 QName endElementName = fElementStack.popElement();
1667
1668 String rawname = endElementName.rawname;
1669 if(DEBUG)System.out.println("endElementName = " + endElementName.toString());
1670 // Take advantage of the fact that next string _should_ be "fElementQName.rawName",
1671 //In scanners most of the time is consumed on checks done for XML characters, we can
1672 // optimize on it and avoid the checks done for endElement,
1673 //we will also avoid symbol table lookup.
1674
1675 // this should work both for namespace processing true or false...
1676
1677 //REVISIT: if the string is not the same as expected.. we need to do better error handling..
1678 //We can skip this for now... In any case if the string doesn't match -- document is not well formed.
1679
1680 if (!fEntityScanner.skipString(endElementName.rawname)) {
1681 reportFatalError("ETagRequired", new Object[]{rawname});
1682 }
1683
1684 // end
1685 fEntityScanner.skipSpaces();
1686 if (!fEntityScanner.skipChar('>', NameType.ELEMENTEND)) {
1687 reportFatalError("ETagUnterminated",
1688 new Object[]{rawname});
1689 }
1690 fMarkupDepth--;
1691
1692 //we have increased the depth for two markup "<" characters
1693 fMarkupDepth--;
2444 for( int i = 0 ; i < fDepth ; i++){
2445 System.out.println("fElements[" + i + "]" + " = " + fElements[i].rawname);
2446 }
2447 }
2448 }
2449
2450 /** Clears the stack without throwing away existing QName objects. */
2451 public void clear() {
2452 fDepth = 0;
2453 fLastDepth = 0;
2454 fCount = 0 ;
2455 fPosition = fMark = 1;
2456
2457 } // clear()
2458
2459 /**
2460 * This function is as a result of optimization done for endElement --
2461 * we dont need to set the value for every end element encouterd.
2462 * For Well formedness checks we can have the same QName object that was pushed.
2463 * the values will be set only if application need to know about the endElement
2464 */
2465
2466 public QName getLastPoppedElement(){
2467 return fElements[fDepth];
2468 }
2469 } // class ElementStack
2470
2471 /**
2472 * Drives the parser to the next state/event on the input. Parser is guaranteed
2473 * to stop at the next state/event.
2474 *
2475 * Internally XML document is divided into several states. Each state represents
2476 * a sections of XML document. When this functions returns normally, it has read
2477 * the section of XML document and returns the state corresponding to section of
2478 * document which has been read. For optimizations, a particular driver
2479 * can read ahead of the section of document (state returned) just read and
2480 * can maintain a different internal state.
2481 *
2482 *
2483 * @author Neeraj Bajaj, Sun Microsystems
|