Package org.apache.xmlbeans.XmlCursor

Examples of org.apache.xmlbeans.XmlCursor.TokenType


    {
        if (node == null)
            throw new IllegalArgumentException("Null node");
        if (nsctx == null)
            throw new IllegalArgumentException("Null namespace context");
        TokenType tt = node.currentTokenType();
        if (context != null && node.isAtSamePositionAs(context))
            return ".";
        switch (tt.intValue())
        {
            case TokenType.INT_ATTR:
                QName name = node.getName();
                node.toParent();
                String pathToParent = generateInternal(node, context, nsctx);
                return pathToParent + '/' + '@' + qnameToString(name, nsctx);
            case TokenType.INT_NAMESPACE:
                name = node.getName();
                node.toParent();
                pathToParent = generateInternal(node, context, nsctx);
                String prefix = name.getLocalPart();
                if (prefix.length() == 0)
                    return pathToParent + "/@xmlns";
                else
                    return pathToParent + "/@xmlns:" + prefix;
            case TokenType.INT_START:
            case TokenType.INT_STARTDOC:
                return generateInternal(node, context, nsctx);
            case TokenType.INT_TEXT:
                int nrOfTextTokens = countTextTokens(node);
                node.toParent();
                pathToParent = generateInternal(node, context, nsctx);
                if (nrOfTextTokens == 0)
                    return pathToParent + "/text()";
                else
                    return pathToParent + "/text()[position()=" + nrOfTextTokens + ']';
            default:
                throw new XPathGenerationException("Cannot generate XPath for cursor position: " +
                    tt.toString());
        }
    }
View Full Code Here


        int k = 0;
        int l = 0;
        XmlCursor d = c.newCursor();
        c.push();
        c.toParent();
        TokenType tt = c.toFirstContentToken();
        while (!tt.isEnd())
        {
            if (tt.isText())
            {
                if (c.comparePosition(d) > 0)
                    // We have moved after the initial position
                    l++;
                else
                    k++;
            }
            else if (tt.isStart())
                c.toEndToken();
            tt = c.toNextToken();
        }
        c.pop();
        return l == 0 ? 0 : k;
View Full Code Here

   * target element.
   * @param cursor The cursor instance.
   * @param toElement The target DOM Element.
   */
  private static void serialize(XmlCursor cursor, Element toElement) {
    TokenType token;
    Document doc = toElement.getOwnerDocument();

    while(true) {
      token = cursor.toNextToken();

      switch (token.intValue()) {
      case TokenType.INT_ATTR:
        toElement.setAttribute(cursor.getName().getLocalPart(), cursor.getTextValue());
        break;
      case TokenType.INT_COMMENT:
        toElement.appendChild(doc.createComment(cursor.getTextValue()));
View Full Code Here

   * target element.
   * @param cursor The cursor instance.
   * @param toElement The target DOM Element.
   */
  private static void serialize(XmlCursor cursor, Element toElement) {
    TokenType token;
    Document doc = toElement.getOwnerDocument();

    while(true) {
      token = cursor.toNextToken();
     
      switch (token.intValue()) {
      case TokenType.INT_ATTR:
        toElement.setAttribute(cursor.getName().getLocalPart(), cursor.getTextValue());
        break;
      case TokenType.INT_COMMENT:
        toElement.appendChild(doc.createComment(cursor.getTextValue()));
View Full Code Here

   * target element.
   * @param cursor The cursor instance.
   * @param toElement The target DOM Element.
   */
  private static void serialize(XmlCursor cursor, Element toElement) {
    TokenType token;
    Document doc = toElement.getOwnerDocument();

    while(true) {
      token = cursor.toNextToken();
     
      switch (token.intValue()) {
      case TokenType.INT_ATTR:
        toElement.setAttribute(cursor.getName().getLocalPart(), cursor.getTextValue());
        break;
      case TokenType.INT_COMMENT:
        toElement.appendChild(doc.createComment(cursor.getTextValue()));
View Full Code Here

   * target element.
   * @param cursor The cursor instance.
   * @param toElement The target DOM Element.
   */
  private static void serialize(XmlCursor cursor, Element toElement) {
    TokenType token;
    Document doc = toElement.getOwnerDocument();

    while(true) {
      token = cursor.toNextToken();

      switch (token.intValue()) {
      case TokenType.INT_ATTR:
        toElement.setAttribute(cursor.getName().getLocalPart(), cursor.getTextValue());
        break;
      case TokenType.INT_COMMENT:
        toElement.appendChild(doc.createComment(cursor.getTextValue()));
View Full Code Here

        //count of body objects
        int iBodyCnt = 0;
        int depth = 1;

        while (cursor.hasNextToken() && depth > 0) {
            TokenType t = cursor.toNextToken();
            if (t.isText()){
                sb.append(cursor.getTextValue());
            } else if (isStartToken(cursor, "tr")) {
                tcCnt = 0;
                iBodyCnt = 0;
            } else if (isStartToken(cursor, "tc")) {
View Full Code Here

    protected ElementXmlTreeNode( XmlCursor cursor, XmlTreeNode parent )
    {
      super( cursor, parent );

      TokenType token = cursor.toNextToken();
      while( token == TokenType.ATTR || token == TokenType.NAMESPACE )
      {
        if( token == TokenType.ATTR )
        {
          elements.add( new AttributeXmlTreeNode( cursor, this ) );
View Full Code Here

        int n = 0;
       
        for ( ; ; )
        {
            TokenType t = c.toNextToken();

            n++;
           
            if (t == TokenType.NONE)
                break;
View Full Code Here

        for ( ; ; )
        {
            Assert.assertTrue( cFrom.comparePosition( cTo ) == 0 );
            Assert.assertTrue( cFrom.isAtSamePositionAs( cTo ) );

            TokenType tt = cFrom.currentTokenType();
           
            if (tt == TokenType.ENDDOC)
            {
                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.