当前位置: 首页>>代码示例>>Java>>正文


Java XmlCursor.isAttr方法代码示例

本文整理汇总了Java中org.apache.xmlbeans.XmlCursor.isAttr方法的典型用法代码示例。如果您正苦于以下问题:Java XmlCursor.isAttr方法的具体用法?Java XmlCursor.isAttr怎么用?Java XmlCursor.isAttr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.xmlbeans.XmlCursor的用法示例。


在下文中一共展示了XmlCursor.isAttr方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hasSimpleContent

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @return
 */
boolean hasSimpleContent()
{
    boolean simpleContent = false;

    XmlCursor curs = newCursor();

    if (curs.isAttr() || curs.isText()) {
        return true;
    }

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

    simpleContent = !(curs.toFirstChild());

    curs.dispose();

    return simpleContent;
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:26,代码来源:XML.java

示例2: localName

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @return
 */
String localName()
{
    XmlCursor cursor = newCursor();
    if (cursor.isStartdoc())
        cursor.toFirstContentToken();

    String name = null;

    if(cursor.isStart() ||
       cursor.isAttr() ||
       cursor.isProcinst())
    {
        javax.xml.namespace.QName qname = cursor.getName();
        name = qname.getLocalPart();
    }
    cursor.dispose();

    return name;
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:24,代码来源:XML.java

示例3: attributesEqual

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param xmlOne
 * @param xmlTwo
 * @return
 */
private static boolean attributesEqual(XmlCursor xmlOne, XmlCursor xmlTwo)
{
    boolean result = false;

    if (xmlOne.isAttr() && xmlTwo.isAttr())
    {
        if (qnamesEqual(xmlOne.getName(), xmlTwo.getName()))
        {
            if (xmlOne.getTextValue().equals(xmlTwo.getTextValue()))
            {
                result = true;
            }
        }
    }

    return result;
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:24,代码来源:LogicalEquality.java

示例4: createAttributeXML

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 * Special constructor for making an attribute
 *
 */
private static XML createAttributeXML(XMLLibImpl lib, XmlCursor cursor)
{
    if (!cursor.isAttr())
        throw new IllegalArgumentException();

    XScriptAnnotation anno = new XScriptAnnotation(cursor);
    cursor.setBookmark(anno);

    return new XML(lib, anno);
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:15,代码来源:XML.java

示例5: namespace

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param prefix
 * @return
 */
Object namespace(String prefix)
{
    XmlCursor cursor = newCursor();
    if (cursor.isStartdoc())
    {
        cursor.toFirstContentToken();
    }

    Object result = null;

    if (prefix == null)
    {
        if(cursor.isStart() ||
           cursor.isAttr())
        {
            Object[] inScopeNS = NamespaceHelper.inScopeNamespaces(lib, cursor);
            // XXX Is it reaaly necessary to create the second cursor?
            XmlCursor cursor2 = newCursor();
            if (cursor2.isStartdoc())
                cursor2.toFirstContentToken();

            result = NamespaceHelper.getNamespace(lib, cursor2, inScopeNS);

            cursor2.dispose();
        }
    }
    else
    {
        Map prefixToURI = NamespaceHelper.getAllNamespaces(lib, cursor);
        String uri = (String)prefixToURI.get(prefix);
        result = (uri == null) ? Undefined.instance : new Namespace(lib, prefix, uri);
    }

    cursor.dispose();

    return result;
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:43,代码来源:XML.java

示例6: loadAttributeMap

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param xml
 * @return
 */
private static TreeMap loadAttributeMap(XmlCursor xml)
{
    TreeMap result = new TreeMap();

    while (xml.isAttr())
    {
        result.put(xml.getTextValue(), xml.getName());
        nextToken(xml);
    }

    return result;
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:18,代码来源:LogicalEquality.java

示例7: toXMLString

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @return
 */
String toXMLString(int indent)
{
    // XXX indent is ignored

    String result;

    XmlCursor curs = newCursor();

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

    try
    {
        if (curs.isText())
        {
            result = curs.getChars();
        }
        else if (curs.isAttr())
        {
            result = curs.getTextValue();
        }
        else if (curs.isComment() || curs.isProcinst())
        {
            result = XML.dumpNode(curs, getOptions());

            // todo: XBeans-dependent hack here
            // If it's a comment or PI, take off the xml-frament stuff
            String start = "<xml-fragment>";
            String end = "</xml-fragment>";

            if (result.startsWith(start))
            {
                result = result.substring(start.length());
            }

            if (result.endsWith(end))
            {
                result = result.substring(0, result.length() - end.length());
            }
        }
        else
        {
            result = XML.dumpNode(curs, getOptions());
        }
    }
    finally
    {
        curs.dispose();
    }

    return result;
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:59,代码来源:XML.java

示例8: nodesEqual

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
public static boolean nodesEqual(XmlCursor xmlOne, XmlCursor xmlTwo)
{
    boolean result = false;

    if (xmlOne.isStartdoc())
    {
        xmlOne.toFirstContentToken();
    }

    if (xmlTwo.isStartdoc())
    {
        xmlTwo.toFirstContentToken();
    }

    if (xmlOne.currentTokenType() == xmlTwo.currentTokenType())
    {
        if (xmlOne.isEnddoc())
        {
            // Both empty
            result = true;
        }
        else if (xmlOne.isAttr())
        {
            result = attributesEqual(xmlOne, xmlTwo);
        }
        else if (xmlOne.isText())
        {
            result = textNodesEqual(xmlOne, xmlTwo);
        }
        else if (xmlOne.isComment())
        {
            result = commentsEqual(xmlOne, xmlTwo);
        }
        else if (xmlOne.isProcinst())
        {
            result = processingInstructionsEqual(xmlOne, xmlTwo);
        }
        else if (xmlOne.isStart())
        {
            // Compare root elements
            result = elementsEqual(xmlOne, xmlTwo);
        }
    }

    return result;
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:47,代码来源:LogicalEquality.java

示例9: elementsEqual

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
private static boolean elementsEqual(XmlCursor xmlOne, XmlCursor xmlTwo)
{
    boolean result = true;

    if (!qnamesEqual(xmlOne.getName(), xmlTwo.getName()))
    {
        result = false;
    }
    else
    {
        // These filter out empty text nodes.
        nextToken(xmlOne);
        nextToken(xmlTwo);

        do
        {
            if (xmlOne.currentTokenType() != xmlTwo.currentTokenType())
            {
                // Not same token
                result = false;
                break;
            }
            else if (xmlOne.isEnd())
            {
                // Done with this element, step over end
                break;
            }
            else if (xmlOne.isEnddoc())
            {
                // Shouldn't get here
                break;
            }
            else if (xmlOne.isAttr())
            {
                // This one will move us to the first non-attr token.
                result = attributeListsEqual(xmlOne, xmlTwo);
            }
            else
            {
                if (xmlOne.isText())
                {
                    result = textNodesEqual(xmlOne, xmlTwo);
                }
                else if (xmlOne.isComment())
                {
                    result = commentsEqual(xmlOne, xmlTwo);
                }
                else if (xmlOne.isProcinst())
                {
                    result = processingInstructionsEqual(xmlOne, xmlTwo);
                }
                else if (xmlOne.isStart())
                {
                    result = elementsEqual(xmlOne, xmlTwo);
                }
                else
                {
                    //XML.log("Unknown token type" + xmlOne.currentTokenType());
                }

                // These filter out empty text nodes.
                nextToken(xmlOne);
                nextToken(xmlTwo);
            }
        }
        while(result);
    }

    return result;
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:71,代码来源:LogicalEquality.java

示例10: assertAttributesEqual

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 * Compares the attributes of the elements at the current position of two XmlCursors.
 * The ordering of the attributes is ignored in the comparison.  Fails the JUnit test
 * case if the attributes or their values are different.
 *
 * @param message to display on test failure (may be null)
 * @param expected
 * @param actual
 */
private static void assertAttributesEqual(String message, XmlCursor expected, XmlCursor actual)
{
  Map<QName,String> map1 = new HashMap<QName,String>();
  Map<QName,String> map2 = new HashMap<QName,String>();

  boolean attr1 = expected.toFirstAttribute();
  boolean attr2 = actual.toFirstAttribute();
  if (attr1 != attr2)
  {
    if (expected.isAttr() || actual.isAttr())
    {
      expected.toParent();
    }
    fail(message, "Differing number of attributes for element: '" + QNameHelper.pretty(expected.getName()) + "'");
  }
  else if (!attr1)
  {
    return;
  }
  else
  {
    map1.put(expected.getName(), expected.getTextValue());
    map2.put(actual.getName(), actual.getTextValue());
  }
  while (true)
  {
    attr1 = expected.toNextAttribute();
    attr2 = actual.toNextAttribute();
    if (attr1 != attr2)
    {
      if (expected.isAttr() || actual.isAttr())
      {
        expected.toParent();
      }
      fail(message, "Differing number of attributes for element: '" + QNameHelper.pretty(expected.getName()) + "'");
    }
    else if (!attr1)
    {
      break;
    }
    else
    {
      map1.put(expected.getName(), expected.getTextValue());
      map2.put(actual.getName(), actual.getTextValue());
    }
  }

  expected.toParent();
  actual.toParent();

  // check that attribute maps match, neglecting order
  Iterator<QName> iter = map1.keySet().iterator();
  while (iter.hasNext())
  {
    QName name = iter.next();
    String value1 = map1.get(name);
    String value2 = map2.get(name);
    if (value2 == null)
    {
      fail(message, "Expected attribute value missing for element: "
          + QNameHelper.pretty(expected.getName()) + "--> '" + name + "'");
    }
    else if (!value2.equals(value1))
    {
      fail(message, "Attribute values for element '" + QNameHelper.pretty(expected.getName())
          + "':  Expected '" + value1 + "', Actual '" + value2 + "'");
    }
  }
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:79,代码来源:XmlBeanAssert.java


注:本文中的org.apache.xmlbeans.XmlCursor.isAttr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。