mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 09:09:38 +02:00
Merge pull request #501 from Flowdalic/fix-redundant-namespaces
Fix redundant namespaces
This commit is contained in:
commit
ab92bc4b40
14 changed files with 144 additions and 47 deletions
|
@ -202,7 +202,7 @@ public abstract class IQ extends Stanza implements IqView {
|
|||
|
||||
// Add the query section if there is one.
|
||||
IQChildElementXmlStringBuilder iqChildElement = getIQChildElementBuilder(
|
||||
new IQChildElementXmlStringBuilder(this));
|
||||
new IQChildElementXmlStringBuilder(getChildElementName(), getChildElementNamespace(), null, xml.getXmlEnvironment()));
|
||||
// TOOD: Document the cases where iqChildElement is null but childElementName not. And if there are none, change
|
||||
// the logic.
|
||||
if (iqChildElement == null) {
|
||||
|
@ -399,17 +399,16 @@ public abstract class IQ extends Stanza implements IqView {
|
|||
|
||||
private boolean isEmptyElement;
|
||||
|
||||
private IQChildElementXmlStringBuilder(IQ iq) {
|
||||
this(iq.getChildElementName(), iq.getChildElementNamespace());
|
||||
public IQChildElementXmlStringBuilder(ExtensionElement extensionElement,
|
||||
XmlEnvironment enclosingXmlEnvironment) {
|
||||
this(extensionElement.getElementName(), extensionElement.getNamespace(), extensionElement.getLanguage(),
|
||||
enclosingXmlEnvironment);
|
||||
}
|
||||
|
||||
public IQChildElementXmlStringBuilder(ExtensionElement pe) {
|
||||
this(pe.getElementName(), pe.getNamespace());
|
||||
}
|
||||
|
||||
private IQChildElementXmlStringBuilder(String element, String namespace) {
|
||||
prelude(element, namespace);
|
||||
this.element = element;
|
||||
private IQChildElementXmlStringBuilder(String elementName, String xmlNs, String xmlLang,
|
||||
XmlEnvironment enclosingXmlEnvironment) {
|
||||
super(elementName, xmlNs, xmlLang, enclosingXmlEnvironment);
|
||||
this.element = elementName;
|
||||
}
|
||||
|
||||
public void setEmptyElement() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2014-2020 Florian Schmaus
|
||||
* Copyright 2014-2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -53,11 +53,13 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
}
|
||||
|
||||
public XmlStringBuilder(FullyQualifiedElement element, XmlEnvironment enclosingXmlEnvironment) {
|
||||
sb = new LazyStringBuilder();
|
||||
halfOpenElement(element);
|
||||
this(element.getElementName(), element.getNamespace(), element.getLanguage(), enclosingXmlEnvironment);
|
||||
}
|
||||
|
||||
public XmlStringBuilder(String elementName, String xmlNs, String xmlLang, XmlEnvironment enclosingXmlEnvironment) {
|
||||
sb = new LazyStringBuilder();
|
||||
halfOpenElement(elementName);
|
||||
|
||||
String xmlNs = element.getNamespace();
|
||||
String xmlLang = element.getLanguage();
|
||||
if (enclosingXmlEnvironment == null) {
|
||||
xmlnsAttribute(xmlNs);
|
||||
xmllangAttribute(xmlLang);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue