Package org.apache.xmlbeans.XmlCursor

Examples of org.apache.xmlbeans.XmlCursor.TokenType


    }

    public TokenType _prevTokenType() {
        _cur.push();

        TokenType tt = _toPrevToken();

        _cur.pop();

        return tt;
    }
View Full Code Here


    }

    public TokenType _prevTokenType() {
        _cur.push();

        TokenType tt = _toPrevToken();

        _cur.pop();

        return tt;
    }
View Full Code Here

     * @param curs
     * @return
     */
    private static TokenType skipNonElements (XmlCursor curs)
    {
        TokenType tt = curs.currentTokenType();
        while (tt.isComment() || tt.isProcinst())
        {
            tt = curs.toNextToken();
        }

        return tt;
View Full Code Here

            // We always move to the children of the top node.
            // todo:  This assumes that we want have multiple top-level nodes.  Which we should be able tohave.
            curs.toFirstContentToken();
        }

        TokenType tt = curs.toFirstContentToken();
        if (!tt.isNone() && !tt.isEnd())
        {
            while (true)
            {
                if (index == idxChild)
                {
                    return true;
                }

                tt = curs.currentTokenType();
                if (tt.isText())
                {
                    curs.toNextToken();
                }
                else if (tt.isStart())
                {
                    // Need to do this we want to be pointing at the text if that after the end token.
                    curs.toEndToken();
                    curs.toNextToken();
                }
                else if (tt.isComment() || tt.isProcinst())
                {
                    continue;
                }
                else
                {
View Full Code Here

     * @return
     */
    private boolean moveSrcToDest (XmlCursor srcCurs, XmlCursor destCurs, boolean fDontMoveIfSame)
    {
        boolean fMovedSomething = true;
        TokenType tt;
        do
        {
            if (fDontMoveIfSame && srcCurs.isInSameDocument(destCurs) && (srcCurs.comparePosition(destCurs) == 0))
            {
                // If the source and destination are pointing at the same place then there's nothing to move.
                fMovedSomething = false;
                break;
            }

            // todo ***TLL*** Use replaceContents (when added) and eliminate children removes (see above todo).
            if (destCurs.currentTokenType().isStartdoc())
            {
                destCurs.toNextToken();
            }

            // todo ***TLL*** Can Eric support notion of copy instead of me copying then moving???
            XmlCursor copyCurs = copy(srcCurs);

            copyCurs.moveXml(destCurs);

            copyCurs.dispose();

            tt = srcCurs.currentTokenType();
        } while (!tt.isStart() && !tt.isEnd() && !tt.isEnddoc());

        return fMovedSomething;
    }
View Full Code Here

     * @param addToType
     */
    private void insertChild(XML childToMatch, Object xmlToInsert, int addToType)
    {
        XmlCursor curs = newCursor();
        TokenType tt = curs.currentTokenType();
        XmlCursor xmlChildCursor = childToMatch.newCursor();

        if (tt.isStartdoc())
        {
            tt = curs.toFirstContentToken();
        }

        if (tt.isContainer())
        {
            tt = curs.toNextToken();

            while (!tt.isEnd())
            {
                if (tt.isStart())
                {
                    // See if this child is the same as the one thep passed in
                    if (curs.comparePosition(xmlChildCursor) == 0)
                    {
                        // Found it
                        if (addToType == APPEND_CHILD)
                        {
                            // Move the cursor to just past the end of this element
                            curs.toEndToken();
                            curs.toNextToken();
                        }

                        insertChild(curs, xmlToInsert);
                        break;
                    }
                }

                // Skip over child elements
                if (tt.isStart())
                {
                    tt = curs.toEndToken();
                }

                tt = curs.toNextToken();
View Full Code Here

        XmlCursor curs = newCursor();
        while (curs.toParent()) {
          /* Goto the top of the document */
        }

        TokenType tt = curs.currentTokenType();
        if (tt.isStartdoc())
        {
            tt = curs.toFirstContentToken();
        }

        if (tt.isStart())
        {
            do
            {
                if (tt.isStart() || tt.isAttr() || tt.isNamespace())
                {
                    javax.xml.namespace.QName currQName = curs.getName();
                    if (oldURI.equals(currQName.getNamespaceURI()))
                    {
                        curs.setName(new javax.xml.namespace.QName(newURI, currQName.getLocalPart()));
                    }
                }

                tt = curs.toNextToken();
            } while (!tt.isEnddoc() && !tt.isNone());
        }

        curs.dispose();
    }
View Full Code Here

        XmlCursor childCurs = newCursor();

        if (childCurs.currentTokenType().isStartdoc())
        {
            // Remove on the document removes all children.
            TokenType tt = childCurs.toFirstContentToken();
            while (!tt.isEnd() && !tt.isEnddoc())
            {
                removeToken(childCurs);
                tt = childCurs.currentTokenType();      // Now see where we're pointing after the delete -- next token.
            }
        }
View Full Code Here

     */
    private XMLList allChildNodes(String namespace)
    {
        XMLList result = new XMLList(lib);
        XmlCursor curs = newCursor();
        TokenType tt = curs.currentTokenType();
        javax.xml.namespace.QName targetProperty = new javax.xml.namespace.QName(namespace, "*");

        if (tt.isStartdoc())
        {
            tt = curs.toFirstContentToken();
        }

        if (tt.isContainer())
        {
            tt = curs.toFirstContentToken();

            while (!tt.isEnd())
            {
                if (!tt.isStart())
                {
                    // Not an element
                    result.addToList(findAnnotation(curs));

                    // Reset target property to null in this case
                    targetProperty = null;
                }
                else
                {
                    // Match namespace as well if specified
                    if (namespace == null ||
                        namespace.length() == 0 ||
                        namespace.equals("*") ||
                        curs.getName().getNamespaceURI().equals(namespace))
                    {
                        // Add it to the list
                        result.addToList(findAnnotation(curs));

                        // Set target property if target name is "*",
                        // Otherwise if target property does not match current, then
                        // set to null
                        if (targetProperty != null)
                        {
                            if (targetProperty.getLocalPart().equals("*"))
                            {
                                targetProperty = curs.getName();
                            }
                            else if (!targetProperty.getLocalPart().equals(curs.getName().getLocalPart()))
                            {
                                // Not a match, unset target property
                                targetProperty = null;
                            }
                        }
                    }
                }

                // Skip over child elements
                if (tt.isStart())
                {
                    tt = curs.toEndToken();
                }

                tt = curs.toNextToken();
View Full Code Here

     */
    private XMLList matchDescendantAttributes(XMLName xmlName)
    {
        XMLList result = new XMLList(lib);
        XmlCursor curs = newCursor();
        TokenType tt = curs.currentTokenType();

        // Set the targets for this XMLList.
        result.setTargets(this, null);

        if (tt.isStartdoc())
        {
            tt = curs.toFirstContentToken();
        }

        if (tt.isContainer())
        {
            int nestLevel = 1;

            while (nestLevel > 0)
            {
                tt = curs.toNextToken();

                // Only try to match names for attributes
                if (tt.isAttr())
                {
                    if (qnameMatches(xmlName, curs.getName()))
                    {
                        result.addToList(findAnnotation(curs));
                    }
                }

                if (tt.isStart())
                {
                    nestLevel++;
                }
                else if (tt.isEnd())
                {
                    nestLevel--;
                }
                else if (tt.isEnddoc())
                {
                    // Shouldn't get here, but just in case.
                    break;
                }
            }
View Full Code Here

TOP

Related Classes of org.apache.xmlbeans.XmlCursor.TokenType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.