public List<QName> getAttributes() { return internal.getAttributes(); }
public List<QName> getAttributes() { return internal.getAttributes(); }
@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(); } }
@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()); } }
jstream.writeField("name", getName(childqname)); jstream.writeField("attributes"); List<QName> attributes = child.getAttributes(); jstream.startObject(); if (!isSameNamespace(childqname, parentqname)) {
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(); }