Example usage for javax.xml.stream XMLStreamConstants END_ELEMENT

List of usage examples for javax.xml.stream XMLStreamConstants END_ELEMENT

Introduction

In this page you can find the example usage for javax.xml.stream XMLStreamConstants END_ELEMENT.

Prototype

int END_ELEMENT

To view the source code for javax.xml.stream XMLStreamConstants END_ELEMENT.

Click Source Link

Document

Indicates an event is an end element

Usage

From source file:com.microsoft.windowsazure.storage.table.TableParser.java

/**
 * Reserved for internal use. Parses the operation response as a collection of entities. Reads entity data from the
 * specified input stream using the specified class type and optionally projects each entity result with the
 * specified resolver into an {@link ODataPayload} containing a collection of {@link TableResult} objects.
 * //from   ww w.j a  v  a 2 s .co  m
 * @param inStream
 *            The <code>InputStream</code> to read the data to parse from.
 * @param clazzType
 *            The class type <code>T</code> implementing {@link TableEntity} for the entities returned. Set to
 *            <code>null</code> to ignore the returned entities and copy only response properties into the
 *            {@link TableResult} objects.
 * @param resolver
 *            An {@link EntityResolver} instance to project the entities into instances of type <code>R</code>. Set
 *            to <code>null</code> to return the entities as instances of the class type <code>T</code>.
 * @param opContext
 *            An {@link OperationContext} object used to track the execution of the operation.
 * @return
 *         An {@link ODataPayload} containing a collection of {@link TableResult} objects with the parsed operation
 *         response.
 * 
 * @throws XMLStreamException
 *             if an error occurs while accessing the stream.
 * @throws ParseException
 *             if an error occurs while parsing the stream.
 * @throws InstantiationException
 *             if an error occurs while constructing the result.
 * @throws IllegalAccessException
 *             if an error occurs in reflection while parsing the result.
 * @throws StorageException
 *             if a storage service error occurs.
 */
@SuppressWarnings("unchecked")
private static <T extends TableEntity, R> ODataPayload<?> parseAtomQueryResponse(final InputStream inStream,
        final Class<T> clazzType, final EntityResolver<R> resolver, final OperationContext opContext)
        throws XMLStreamException, ParseException, InstantiationException, IllegalAccessException,
        StorageException {
    ODataPayload<T> corePayload = null;
    ODataPayload<R> resolvedPayload = null;
    ODataPayload<?> commonPayload = null;

    if (resolver != null) {
        resolvedPayload = new ODataPayload<R>();
        commonPayload = resolvedPayload;
    } else {
        corePayload = new ODataPayload<T>();
        commonPayload = corePayload;
    }

    final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(inStream);
    int eventType = xmlr.getEventType();
    xmlr.require(XMLStreamConstants.START_DOCUMENT, null, null);
    eventType = xmlr.next();

    xmlr.require(XMLStreamConstants.START_ELEMENT, null, ODataConstants.FEED);
    // skip feed chars
    eventType = xmlr.next();

    while (xmlr.hasNext()) {
        eventType = xmlr.next();

        if (eventType == XMLStreamConstants.CHARACTERS) {
            xmlr.getText();
            continue;
        }

        final String name = xmlr.getName().toString();

        if (eventType == XMLStreamConstants.START_ELEMENT) {
            if (name.equals(ODataConstants.BRACKETED_ATOM_NS + ODataConstants.ENTRY)) {
                final TableResult res = parseAtomEntity(xmlr, clazzType, resolver, opContext);
                if (corePayload != null) {
                    corePayload.tableResults.add(res);
                }

                if (resolver != null) {
                    resolvedPayload.results.add((R) res.getResult());
                } else {
                    corePayload.results.add((T) res.getResult());
                }
            }
        } else if (eventType == XMLStreamConstants.END_ELEMENT
                && name.equals(ODataConstants.BRACKETED_ATOM_NS + ODataConstants.FEED)) {
            break;
        }
    }

    xmlr.require(XMLStreamConstants.END_ELEMENT, null, ODataConstants.FEED);
    return commonPayload;
}

From source file:com.microsoft.windowsazure.storage.table.TableParser.java

/**
 * Reserved for internal use. Reads the properties of an entity from the stream into a map of property names to
 * typed values. Reads the entity data as an AtomPub Entry Resource from the specified {@link XMLStreamReader} into
 * a map of <code>String</code> property names to {@link EntityProperty} data typed values.
 * //from   w w w. j  a  va  2 s. co m
 * @param xmlr
 *            The <code>XMLStreamReader</code> to read the data from.
 * @param opContext
 *            An {@link OperationContext} object used to track the execution of the operation.
 * 
 * @return
 *         A <code>java.util.HashMap</code> containing a map of <code>String</code> property names to
 *         {@link EntityProperty} data typed values found in the entity data.
 * @throws XMLStreamException
 *             if an error occurs accessing the stream.
 * @throws ParseException
 *             if an error occurs converting the input to a particular data type.
 */
private static HashMap<String, EntityProperty> readAtomProperties(final XMLStreamReader xmlr,
        final OperationContext opContext) throws XMLStreamException, ParseException {
    int eventType = xmlr.getEventType();
    xmlr.require(XMLStreamConstants.START_ELEMENT, null, ODataConstants.PROPERTIES);
    final HashMap<String, EntityProperty> properties = new HashMap<String, EntityProperty>();

    while (xmlr.hasNext()) {
        eventType = xmlr.next();
        if (eventType == XMLStreamConstants.CHARACTERS) {
            xmlr.getText();
            continue;
        }

        if (eventType == XMLStreamConstants.START_ELEMENT
                && xmlr.getNamespaceURI().equals(ODataConstants.DATA_SERVICES_NS)) {
            final String key = xmlr.getLocalName();
            String val = Constants.EMPTY_STRING;
            String edmType = null;

            if (xmlr.getAttributeCount() > 0) {
                edmType = xmlr.getAttributeValue(ODataConstants.DATA_SERVICES_METADATA_NS, ODataConstants.TYPE);
            }

            // move to chars
            eventType = xmlr.next();

            if (eventType == XMLStreamConstants.CHARACTERS) {
                val = xmlr.getText();

                // end element
                eventType = xmlr.next();
            }

            xmlr.require(XMLStreamConstants.END_ELEMENT, null, key);

            final EntityProperty newProp = new EntityProperty(val, EdmType.parse(edmType));
            properties.put(key, newProp);
        } else if (eventType == XMLStreamConstants.END_ELEMENT && xmlr.getName().toString()
                .equals(ODataConstants.BRACKETED_DATA_SERVICES_METADATA_NS + ODataConstants.PROPERTIES)) {
            // End read properties
            break;
        }
    }

    xmlr.require(XMLStreamConstants.END_ELEMENT, null, ODataConstants.PROPERTIES);
    return properties;
}

From source file:ca.uhn.fhir.parser.XmlParser.java

private void encodeXhtml(XhtmlDt theDt, XMLStreamWriter theEventWriter) throws XMLStreamException {
    if (theDt == null || theDt.getValue() == null) {
        return;/* w w  w  .  j a v  a2 s .c  o m*/
    }

    boolean firstElement = true;
    for (XMLEvent event : theDt.getValue()) {
        switch (event.getEventType()) {
        case XMLStreamConstants.ATTRIBUTE:
            Attribute attr = (Attribute) event;
            if (isBlank(attr.getName().getPrefix())) {
                if (isBlank(attr.getName().getNamespaceURI())) {
                    theEventWriter.writeAttribute(attr.getName().getLocalPart(), attr.getValue());
                } else {
                    theEventWriter.writeAttribute(attr.getName().getNamespaceURI(),
                            attr.getName().getLocalPart(), attr.getValue());
                }
            } else {
                theEventWriter.writeAttribute(attr.getName().getPrefix(), attr.getName().getNamespaceURI(),
                        attr.getName().getLocalPart(), attr.getValue());
            }

            break;
        case XMLStreamConstants.CDATA:
            theEventWriter.writeCData(((Characters) event).getData());
            break;
        case XMLStreamConstants.CHARACTERS:
        case XMLStreamConstants.SPACE:
            String data = ((Characters) event).getData();
            theEventWriter.writeCharacters(data);
            break;
        case XMLStreamConstants.COMMENT:
            theEventWriter.writeComment(((Comment) event).getText());
            break;
        case XMLStreamConstants.END_ELEMENT:
            theEventWriter.writeEndElement();
            break;
        case XMLStreamConstants.ENTITY_REFERENCE:
            EntityReference er = (EntityReference) event;
            theEventWriter.writeEntityRef(er.getName());
            break;
        case XMLStreamConstants.NAMESPACE:
            Namespace ns = (Namespace) event;
            theEventWriter.writeNamespace(ns.getPrefix(), ns.getNamespaceURI());
            break;
        case XMLStreamConstants.START_ELEMENT:
            StartElement se = event.asStartElement();
            if (firstElement) {
                if (StringUtils.isBlank(se.getName().getPrefix())) {
                    String namespaceURI = se.getName().getNamespaceURI();
                    if (StringUtils.isBlank(namespaceURI)) {
                        namespaceURI = "http://www.w3.org/1999/xhtml";
                    }
                    theEventWriter.writeStartElement(se.getName().getLocalPart());
                    theEventWriter.writeDefaultNamespace(namespaceURI);
                } else {
                    String prefix = se.getName().getPrefix();
                    String namespaceURI = se.getName().getNamespaceURI();
                    theEventWriter.writeStartElement(prefix, se.getName().getLocalPart(), namespaceURI);
                    theEventWriter.writeNamespace(prefix, namespaceURI);
                }
                firstElement = false;
            } else {
                if (isBlank(se.getName().getPrefix())) {
                    if (isBlank(se.getName().getNamespaceURI())) {
                        theEventWriter.writeStartElement(se.getName().getLocalPart());
                    } else {
                        if (StringUtils.isBlank(se.getName().getPrefix())) {
                            theEventWriter.writeStartElement(se.getName().getLocalPart());
                            // theEventWriter.writeDefaultNamespace(se.getName().getNamespaceURI());
                        } else {
                            theEventWriter.writeStartElement(se.getName().getNamespaceURI(),
                                    se.getName().getLocalPart());
                        }
                    }
                } else {
                    theEventWriter.writeStartElement(se.getName().getPrefix(), se.getName().getLocalPart(),
                            se.getName().getNamespaceURI());
                }
                for (Iterator<?> attrIter = se.getAttributes(); attrIter.hasNext();) {
                    Attribute next = (Attribute) attrIter.next();
                    theEventWriter.writeAttribute(next.getName().getLocalPart(), next.getValue());
                }
            }
            break;
        case XMLStreamConstants.DTD:
        case XMLStreamConstants.END_DOCUMENT:
        case XMLStreamConstants.ENTITY_DECLARATION:
        case XMLStreamConstants.NOTATION_DECLARATION:
        case XMLStreamConstants.PROCESSING_INSTRUCTION:
        case XMLStreamConstants.START_DOCUMENT:
            break;
        }

    }
}

From source file:com.ibm.bi.dml.runtime.controlprogram.parfor.opt.PerfTestTool.java

/**
 * //from  w  ww.j a  v a  2  s .  c om
 * @param fname
 * @throws XMLStreamException
 * @throws IOException
 */
private static void readProfile(String fname) throws XMLStreamException, IOException {
    //init profile map
    _profile = new HashMap<Integer, HashMap<Integer, CostFunction>>();

    //read existing profile
    FileInputStream fis = new FileInputStream(fname);

    try {
        //xml parsing
        XMLInputFactory xif = XMLInputFactory.newInstance();
        XMLStreamReader xsr = xif.createXMLStreamReader(fis);

        int e = xsr.nextTag(); // profile start

        while (true) //read all instructions
        {
            e = xsr.nextTag(); // instruction start
            if (e == XMLStreamConstants.END_ELEMENT)
                break; //reached profile end tag

            //parse instruction
            int ID = Integer.parseInt(xsr.getAttributeValue(null, XML_ID));
            //String name = xsr.getAttributeValue(null, XML_NAME).trim().replaceAll(" ", Lops.OPERAND_DELIMITOR);
            HashMap<Integer, CostFunction> tmp = new HashMap<Integer, CostFunction>();
            _profile.put(ID, tmp);

            while (true) {
                e = xsr.nextTag(); // cost function start
                if (e == XMLStreamConstants.END_ELEMENT)
                    break; //reached instruction end tag

                //parse cost function
                TestMeasure m = TestMeasure.valueOf(xsr.getAttributeValue(null, XML_MEASURE));
                TestVariable lv = TestVariable.valueOf(xsr.getAttributeValue(null, XML_VARIABLE));
                InternalTestVariable[] pv = parseTestVariables(
                        xsr.getAttributeValue(null, XML_INTERNAL_VARIABLES));
                DataFormat df = DataFormat.valueOf(xsr.getAttributeValue(null, XML_DATAFORMAT));
                int tDefID = getTestDefID(m, lv, df, pv);

                xsr.next(); //read characters
                double[] params = parseParams(xsr.getText());
                boolean multidim = _regTestDef.get(tDefID).getInternalVariables().length > 1;
                CostFunction cf = new CostFunction(params, multidim);
                tmp.put(tDefID, cf);

                xsr.nextTag(); // cost function end
                //System.out.println("added cost function");
            }
        }
        xsr.close();
    } finally {
        IOUtilFunctions.closeSilently(fis);
    }

    //mark profile as successfully read
    _flagReadData = true;
}

From source file:nl.nn.adapterframework.validation.XSD.java

public void init() throws ConfigurationException {
    if (noNamespaceSchemaLocation != null) {
        url = ClassUtils.getResourceURL(classLoader, noNamespaceSchemaLocation);
        if (url == null) {
            throw new ConfigurationException("Cannot find [" + noNamespaceSchemaLocation + "]");
        }//www.  ja  va2s .  co m
        resourceTarget = noNamespaceSchemaLocation;
        toString = noNamespaceSchemaLocation;
    } else {
        if (resource != null) {
            url = ClassUtils.getResourceURL(classLoader, resource);
            if (url == null) {
                throw new ConfigurationException("Cannot find [" + resource + "]");
            }
            resourceTarget = resource;
            toString = resource;
            if (resourceInternalReference != null) {
                resourceTarget = resourceTarget + "-" + resourceInternalReference + ".xsd";
                toString = toString + "!" + resourceInternalReference;
            }
        } else if (sourceXsds == null) {
            throw new ConfigurationException(
                    "None of noNamespaceSchemaLocation, resource or mergedResources is specified");
        } else {
            resourceTarget = "[";
            toString = "[";
            boolean first = true;
            for (XSD xsd : sourceXsds) {
                if (first) {
                    first = false;
                } else {
                    resourceTarget = resourceTarget + ", ";
                    toString = toString + ", ";
                }
                resourceTarget = resourceTarget + xsd.getResourceTarget().replaceAll("/", "_");
                toString = toString + xsd.toString();
            }
            resourceTarget = resourceTarget + "].xsd";
            toString = toString + "]";
        }
        if (parentLocation == null) {
            this.parentLocation = "";
        }
    }
    try {
        InputStream in = getInputStream();
        XMLEventReader er = XmlUtils.INPUT_FACTORY.createXMLEventReader(in, XmlUtils.STREAM_FACTORY_ENCODING);
        int elementDepth = 0;
        while (er.hasNext()) {
            XMLEvent e = er.nextEvent();
            switch (e.getEventType()) {
            case XMLStreamConstants.START_ELEMENT:
                elementDepth++;
                StartElement el = e.asStartElement();
                if (el.getName().equals(SchemaUtils.SCHEMA)) {
                    Attribute a = el.getAttributeByName(SchemaUtils.TNS);
                    if (a != null) {
                        xsdTargetNamespace = a.getValue();
                    }
                    Iterator<Namespace> nsIterator = el.getNamespaces();
                    while (nsIterator.hasNext() && StringUtils.isEmpty(xsdDefaultNamespace)) {
                        Namespace ns = nsIterator.next();
                        if (StringUtils.isEmpty(ns.getPrefix())) {
                            xsdDefaultNamespace = ns.getNamespaceURI();
                        }
                    }
                } else if (el.getName().equals(SchemaUtils.IMPORT)) {
                    Attribute a = el.getAttributeByName(SchemaUtils.NAMESPACE);
                    if (a != null) {
                        boolean skip = false;
                        ArrayList ans = null;
                        if (StringUtils.isNotEmpty(getImportedNamespacesToIgnore())) {
                            ans = new ArrayList(Arrays.asList(getImportedNamespacesToIgnore().split(",")));
                        }
                        if (StringUtils.isNotEmpty(a.getValue()) && ans != null) {
                            if (ans.contains(a.getValue())) {
                                skip = true;
                            }
                        }
                        if (!skip) {
                            importedNamespaces.add(a.getValue());
                        }
                    }
                } else if (el.getName().equals(SchemaUtils.ELEMENT)) {
                    if (elementDepth == 2) {
                        rootTags.add(el.getAttributeByName(SchemaUtils.NAME).getValue());
                    }
                }
                break;
            case XMLStreamConstants.END_ELEMENT:
                elementDepth--;
                break;
            }
        }
        this.targetNamespace = xsdTargetNamespace;
        if (namespace == null) {
            // In case WsdlXmlValidator doesn't have schemaLocation
            namespace = xsdTargetNamespace;
        }
    } catch (IOException e) {
        String message = "IOException reading XSD";
        LOG.error(message, e);
        throw new ConfigurationException(message, e);
    } catch (XMLStreamException e) {
        String message = "XMLStreamException reading XSD";
        LOG.error(message, e);
        throw new ConfigurationException(message, e);
    }
}

From source file:org.apache.axiom.om.impl.builder.StAXBuilder.java

/**
 * Method discard.// w  w  w  . j  av a 2  s .c o m
 *
 * @param element
 * @throws OMException
 */
public void discard(OMElement element) throws OMException {

    if (element.isComplete() || !cache) {
        throw new OMException();
    }
    try {

        // We simply cannot use the parser instance from the builder for this case
        // it is not safe to assume that the parser inside the builder will be in
        // sync with the parser of the element in question
        // Note 1 - however  calling getXMLStreamReaderWithoutCaching sets off two flags
        // the cache flag for this builder and the parserAccessed flag. These flags will be
        // reset later in this procedure

        int event = 0;
        XMLStreamReader elementParser = element.getXMLStreamReaderWithoutCaching();
        do {
            event = elementParser.next();
        } while (!(event == XMLStreamConstants.END_ELEMENT
                && element.getLocalName().equals(elementParser.getLocalName())));

        //at this point we are safely at the end_element event of the element we discarded
        lastNode = element.getPreviousOMSibling();

        // resetting the flags - see Note 1 above
        cache = true;
        parserAccessed = false;

        if (lastNode != null) {
            // if the last node is not an element, we are in trouble because leaf nodes
            // (such as text) cannot build themselves. worst the lastchild of the
            // currentparent is still the removed node! we have to correct it
            OMContainerEx ex = ((OMContainerEx) lastNode.getParent());
            ex.setLastChild(lastNode);
            if (!(lastNode instanceof OMContainerEx)) {
                ex.buildNext();
            } else {
                ((OMNodeEx) lastNode).setNextOMSibling(null);
            }

        } else {
            OMElement parent = (OMElement) element.getParent();
            if (parent == null) {
                throw new OMException();
            }
            ((OMContainerEx) parent).setFirstChild(null);
            lastNode = parent;
        }

    } catch (OMException e) {
        throw e;
    } catch (Exception e) {
        throw new OMException(e);
    }
    // when an element is discarded the element index that was incremented
    //at creation needs to be decremented !
    elementLevel--;
}

From source file:org.apache.axiom.om.impl.builder.StAXOMBuilder.java

/**
 * Method next./*  ww w . j a  v a2  s .  co m*/
 *
 * @return Returns int.
 * @throws OMException
 */
public int next() throws OMException {
    try {
        // We need a loop here because we may decide to skip an event
        while (true) {
            if (done) {
                throw new OMException();
            }
            int token = parserNext();
            if (!cache) {
                return token;
            }

            // The current token should be the same as the 
            // one just obtained.  This bit of code is used to 
            // detect invalid parser state.
            if (doTrace) {
                int currentParserToken = parser.getEventType();
                if (currentParserToken != token) {

                    log.debug("WARNING: The current state of the parser is not equal to the "
                            + "state just received from the parser. The current state in the paser is "
                            + XMLEventUtils.getEventTypeString(currentParserToken)
                            + " the state just received is " + XMLEventUtils.getEventTypeString(token));

                    /*
                      throw new OMException("The current token " + token + 
                                 " does not match the current event " +
                                 "reported by the parser token.  The parser did not update its state correctly.  " +
                                 "The parser is " + parser);
                     */
                }
            }

            // Now log the current state of the parser
            if (doTrace) {
                logParserState();
            }

            switch (token) {
            case XMLStreamConstants.START_ELEMENT:
                elementLevel++;
                lastNode = createNextOMElement();
                break;
            case XMLStreamConstants.CHARACTERS:
                lastNode = createOMText(XMLStreamConstants.CHARACTERS);
                break;
            case XMLStreamConstants.CDATA:
                lastNode = createOMText(XMLStreamConstants.CDATA);
                break;
            case XMLStreamConstants.END_ELEMENT:
                endElement();
                elementLevel--;
                break;
            case XMLStreamConstants.END_DOCUMENT:
                done = true;
                ((OMContainerEx) this.document).setComplete(true);
                break;
            case XMLStreamConstants.SPACE:
                try {
                    lastNode = createOMText(XMLStreamConstants.SPACE);
                    if (lastNode == null) {
                        continue;
                    }
                } catch (OMHierarchyException ex) {
                    // The OM implementation doesn't allow text nodes at the current
                    // position in the tree. Since it is only whitespace, we can safely
                    // skip this event.
                    continue;
                }
                break;
            case XMLStreamConstants.COMMENT:
                lastNode = createComment();
                break;
            case XMLStreamConstants.DTD:
                createDTD();
                break;
            case XMLStreamConstants.PROCESSING_INSTRUCTION:
                lastNode = createPI();
                break;
            case XMLStreamConstants.ENTITY_REFERENCE:
                lastNode = createOMText(XMLStreamConstants.ENTITY_REFERENCE);
                break;
            default:
                throw new OMException();
            }
            return token;
        }
    } catch (XMLStreamException e) {
        throw new OMException(e);
    }
}

From source file:org.apache.axiom.om.impl.builder.StAXOMBuilder.java

/**
 * Dump the current event of the parser.
 *//*from   ww  w .  j  a  va  2 s . c  om*/
protected void logParserState() {
    if (doTrace) {
        int currentEvent = parser.getEventType();

        switch (currentEvent) {
        case XMLStreamConstants.START_ELEMENT:
            log.trace("START_ELEMENT: ");
            log.trace("  QName: " + parser.getName());
            break;
        case XMLStreamConstants.START_DOCUMENT:
            log.trace("START_DOCUMENT: ");
            break;
        case XMLStreamConstants.CHARACTERS:
            log.trace("CHARACTERS: ");
            // This can bust up a datahandler
            //log.trace(   "[" + parser.getText() + "]");
            break;
        case XMLStreamConstants.CDATA:
            log.trace("CDATA: ");
            // This can but
            //log.trace(   "[" + parser.getText() + "]");
            break;
        case XMLStreamConstants.END_ELEMENT:
            log.trace("END_ELEMENT: ");
            log.trace("  QName: " + parser.getName());
            break;
        case XMLStreamConstants.END_DOCUMENT:
            log.trace("END_DOCUMENT: ");
            break;
        case XMLStreamConstants.SPACE:
            log.trace("SPACE: ");
            //log.trace(   "[" + parser.getText() + "]");
            break;
        case XMLStreamConstants.COMMENT:
            log.trace("COMMENT: ");
            //log.trace(   "[" + parser.getText() + "]");
            break;
        case XMLStreamConstants.DTD:
            log.trace("DTD: ");
            log.trace("[" + parser.getText() + "]");
            break;
        case XMLStreamConstants.PROCESSING_INSTRUCTION:
            log.trace("PROCESSING_INSTRUCTION: ");
            log.trace("   [" + parser.getPITarget() + "][" + parser.getPIData() + "]");
            break;
        case XMLStreamConstants.ENTITY_REFERENCE:
            log.trace("ENTITY_REFERENCE: ");
            log.trace("    " + parser.getLocalName() + "[" + parser.getText() + "]");
            break;
        default:
            log.trace("UNKNOWN_STATE: " + currentEvent);

        }
    }
}

From source file:org.apache.axiom.om.impl.builder.StAXOMBuilder.java

/**
 * This method looks ahead to the next start element.
 * @return true if successful/*from  ww w  . j a v a  2 s  .c om*/
 */
public boolean lookahead() {
    try {
        while (true) {
            if (lookAheadToken < 0) {
                lookAheadToken = parserNext();
            }
            if (lookAheadToken == XMLStreamConstants.START_ELEMENT) {
                return true;
            } else if (lookAheadToken == XMLStreamConstants.END_ELEMENT
                    || lookAheadToken == XMLStreamConstants.START_DOCUMENT
                    || lookAheadToken == XMLStreamConstants.END_DOCUMENT) {
                next();
                return false; // leaving scope...start element not found
            } else {
                next(); // continue looking past whitespace etc.
            }
        }
    } catch (XMLStreamException e) {
        throw new OMException(e);
    }
}