feat(serialize-xml): use name encoding for values
This commit is contained in:
parent
dc48cc436c
commit
fcc3d97150
|
@ -13,7 +13,7 @@ import java.util.Objects;
|
||||||
import static io.gitlab.jfronny.commons.serialize.xml.impl.WrapperScope.*;
|
import static io.gitlab.jfronny.commons.serialize.xml.impl.WrapperScope.*;
|
||||||
|
|
||||||
public class XmlWriter extends SerializeWriter<IOException, XmlWriter> implements Closeable {
|
public class XmlWriter extends SerializeWriter<IOException, XmlWriter> implements Closeable {
|
||||||
private NativeXmlWriter writer;
|
private final NativeXmlWriter writer;
|
||||||
private int[] stack = new int[32];
|
private int[] stack = new int[32];
|
||||||
private int stackSize = 0;
|
private int stackSize = 0;
|
||||||
private String[] pathNames = new String[32];
|
private String[] pathNames = new String[32];
|
||||||
|
@ -169,9 +169,9 @@ public class XmlWriter extends SerializeWriter<IOException, XmlWriter> implement
|
||||||
beforeValue();
|
beforeValue();
|
||||||
String name = consumeName();
|
String name = consumeName();
|
||||||
if (pathIndices[stackSize - 1] == 0 && heuristics.shouldUseAttribute(name)) {
|
if (pathIndices[stackSize - 1] == 0 && heuristics.shouldUseAttribute(name)) {
|
||||||
writer.attribute(name, null);
|
writer.attribute(nameEncoding.encode(name), null);
|
||||||
} else {
|
} else {
|
||||||
writer.beginTag(name);
|
writer.beginTag(nameEncoding.encode(name));
|
||||||
writer.endTag();
|
writer.endTag();
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
@ -184,11 +184,11 @@ public class XmlWriter extends SerializeWriter<IOException, XmlWriter> implement
|
||||||
if (pathIndices[stackSize - 1] == 0 && heuristics.shouldUseAttribute(name)) {
|
if (pathIndices[stackSize - 1] == 0 && heuristics.shouldUseAttribute(name)) {
|
||||||
writer.attribute(name, value);
|
writer.attribute(name, value);
|
||||||
} else if (heuristics.shouldUseCData(value, name)) {
|
} else if (heuristics.shouldUseCData(value, name)) {
|
||||||
writer.beginTag(name);
|
writer.beginTag(nameEncoding.encode(name));
|
||||||
writer.cdata(value);
|
writer.cdata(value);
|
||||||
writer.endTag();
|
writer.endTag();
|
||||||
} else {
|
} else {
|
||||||
writer.beginTag(name);
|
writer.beginTag(nameEncoding.encode(name));
|
||||||
writer.text(value);
|
writer.text(value);
|
||||||
writer.endTag();
|
writer.endTag();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue