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


Java XmlCursor.toNextAttribute方法代码示例

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


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

示例1: verify_condition

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
private boolean verify_condition(XmlCursor cursor, Condition condition) {
    boolean more, found=false;
    XmlBookmark bookmark = new XmlBookmark(){};
    cursor.setBookmark(bookmark);
    if (condition.isAttribute) {
        for (more=cursor.toFirstAttribute(); more&&!found; more=cursor.toNextAttribute()) {
            if (cursor.getName().getLocalPart().equals(condition.name)) {
                found = cursor.getTextValue().trim().equals(condition.value);
            }
        }
    } else {
        for (more=cursor.toFirstChild(); more&&!found; more=cursor.toNextSibling()) {
            if (cursor.getName().getLocalPart().equals(condition.name)) {
                found = cursor.getTextValue().trim().equals(condition.value);
            }
        }
    }
    cursor.toBookmark(bookmark);
    return found;
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:21,代码来源:XmlPath.java

示例2: matchAttributes

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param name
 * @return
 */
private XMLList matchAttributes(XMLName xmlName)
{
    XMLList result = new XMLList(lib);
    XmlCursor curs = newCursor();

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

    if (curs.isStart())
    {
        if (curs.toFirstAttribute())
        {
            do
            {
                if (qnameMatches(xmlName, curs.getName()))
                {
                    result.addToList(createAttributeObject(curs));
                }
            } while (curs.toNextAttribute());
        }
    }

    curs.dispose();

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

示例3: update

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 * Updates the internal state of this NamespaceHelper with the
 * namespace information of the element pointed to by the cursor.
 */
private void update(XmlCursor cursor, ObjArray declarations)
{
    // Process the Namespace declarations
    cursor.push();
    while(cursor.toNextToken().isAnyAttr())
    {
        if(cursor.isNamespace())
        {
            javax.xml.namespace.QName name = cursor.getName();
            String prefix = name.getLocalPart();
            String uri = name.getNamespaceURI();

            declareNamespace(prefix, uri, declarations);
        }
    }
    cursor.pop();

    // Process the element
    processName(cursor, declarations);

    // Process the attributes
    cursor.push();
    boolean hasNext = cursor.toFirstAttribute();
    while(hasNext)
    {
        processName(cursor, declarations);
        hasNext = cursor.toNextAttribute();
    }
    cursor.pop();
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:35,代码来源:NamespaceHelper.java

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