org.apache.abdera.model.Element.getAttributes()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(155)

本文整理了Java中org.apache.abdera.model.Element.getAttributes()方法的一些代码示例,展示了Element.getAttributes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getAttributes()方法的具体详情如下:
包路径:org.apache.abdera.model.Element
类名称:Element
方法名:getAttributes

Element.getAttributes介绍

[英]Returns a listing of all attributes on this element
[中]返回此元素上所有属性的列表

代码示例

代码示例来源:origin: org.apache.abdera/abdera-core

public List<QName> getAttributes() {
  return internal.getAttributes();
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.abdera

public List<QName> getAttributes() {
 return internal.getAttributes();
}

代码示例来源:origin: org.apache.ws.commons.axiom/fom-testsuite

@Override
  protected void runTest() throws Throwable {
    Element element = abdera.getFactory().newElement(new QName("test"));
    QName qname = new QName("urn:test", "attr", "p");
    element.setAttributeValue(qname, "value");
    assertThat(element.getAttributes()).containsExactly(qname);
    element.setAttributeValue(qname, null);
    assertThat(element.getAttributes()).isEmpty();
  }
}

代码示例来源:origin: org.apache.ws.commons.axiom/fom-testsuite

@Override
  protected void runTest() throws Throwable {
    Element element = abdera.getFactory().newElement(new QName("test"));
    element.setAttributeValue(qname, "value");
    assertThat(element.getAttributeValue(qname)).isEqualTo("value");
    List<QName> attrs = element.getAttributes();
    assertThat(attrs).hasSize(1);
    QName actualQName = attrs.get(0);
    assertThat(actualQName).isEqualTo(qname);
    assertThat(actualQName.getPrefix()).isEqualTo(qname.getPrefix());
  }
}

代码示例来源:origin: org.apache.abdera/abdera-extensions-json

jstream.writeField("name", getName(childqname));
jstream.writeField("attributes");
List<QName> attributes = child.getAttributes();
jstream.startObject();
if (!isSameNamespace(childqname, parentqname)) {

代码示例来源:origin: org.apache.abdera/abdera-extensions-serializer

protected void process(Object source,
            ObjectContext objectContext,
            SerializationContext context,
            Conventions conventions) {
  StreamWriter sw = context.getStreamWriter();
  if (!(source instanceof Element))
    return;
  Element element = (Element)source;
  sw.startElement(element.getQName());
  for (QName attr : element.getAttributes())
    sw.writeAttribute(attr, element.getAttributeValue(attr));
  XPath xpath = context.getAbdera().getXPath();
  List<?> children = xpath.selectNodes("node()", element);
  for (Object child : children) {
    if (child instanceof Element) {
      process(child, new ObjectContext(child), context, conventions);
    } else if (child instanceof Comment) {
      Comment comment = (Comment)child;
      sw.writeComment(comment.getText());
    } else if (child instanceof ProcessingInstruction) {
      ProcessingInstruction pi = (ProcessingInstruction)child;
      sw.writePI(pi.getText(), pi.getTarget());
    } else if (child instanceof TextValue) {
      TextValue tv = (TextValue)child;
      sw.writeElementText(tv.getText());
    }
  }
  sw.endElement();
}

相关文章