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

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

本文整理了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

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

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

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

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

  1. @Override
  2. protected void runTest() throws Throwable {
  3. Element element = abdera.getFactory().newElement(new QName("test"));
  4. QName qname = new QName("urn:test", "attr", "p");
  5. element.setAttributeValue(qname, "value");
  6. assertThat(element.getAttributes()).containsExactly(qname);
  7. element.setAttributeValue(qname, null);
  8. assertThat(element.getAttributes()).isEmpty();
  9. }
  10. }

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

  1. @Override
  2. protected void runTest() throws Throwable {
  3. Element element = abdera.getFactory().newElement(new QName("test"));
  4. element.setAttributeValue(qname, "value");
  5. assertThat(element.getAttributeValue(qname)).isEqualTo("value");
  6. List<QName> attrs = element.getAttributes();
  7. assertThat(attrs).hasSize(1);
  8. QName actualQName = attrs.get(0);
  9. assertThat(actualQName).isEqualTo(qname);
  10. assertThat(actualQName.getPrefix()).isEqualTo(qname.getPrefix());
  11. }
  12. }

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

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

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

  1. protected void process(Object source,
  2. ObjectContext objectContext,
  3. SerializationContext context,
  4. Conventions conventions) {
  5. StreamWriter sw = context.getStreamWriter();
  6. if (!(source instanceof Element))
  7. return;
  8. Element element = (Element)source;
  9. sw.startElement(element.getQName());
  10. for (QName attr : element.getAttributes())
  11. sw.writeAttribute(attr, element.getAttributeValue(attr));
  12. XPath xpath = context.getAbdera().getXPath();
  13. List<?> children = xpath.selectNodes("node()", element);
  14. for (Object child : children) {
  15. if (child instanceof Element) {
  16. process(child, new ObjectContext(child), context, conventions);
  17. } else if (child instanceof Comment) {
  18. Comment comment = (Comment)child;
  19. sw.writeComment(comment.getText());
  20. } else if (child instanceof ProcessingInstruction) {
  21. ProcessingInstruction pi = (ProcessingInstruction)child;
  22. sw.writePI(pi.getText(), pi.getTarget());
  23. } else if (child instanceof TextValue) {
  24. TextValue tv = (TextValue)child;
  25. sw.writeElementText(tv.getText());
  26. }
  27. }
  28. sw.endElement();
  29. }

相关文章