[jOOQ/jOOQ#10387] XMLGenerator should quote source code from views, check constraints, and default expressions in generated output
This commit is contained in:
parent
00f38ce5b1
commit
aa6957e4cc
@ -156,37 +156,42 @@ public final class XMLBuilder {
|
||||
public XMLBuilder append(String elementName, String s) {
|
||||
if (s != null) {
|
||||
openTag(elementName);
|
||||
builder.append(s);
|
||||
builder.append(escape(s));
|
||||
closeTag(elementName).newLine();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public XMLBuilder append(String elementName, Pattern p) {
|
||||
if (p != null) {
|
||||
openTag(elementName);
|
||||
builder.append(p.pattern());
|
||||
closeTag(elementName).newLine();
|
||||
}
|
||||
if (p != null)
|
||||
append(elementName, p.pattern());
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public XMLBuilder append(String elementName, Object o) {
|
||||
if (o != null) {
|
||||
openTag(elementName);
|
||||
builder.append(o);
|
||||
closeTag(elementName).newLine();
|
||||
}
|
||||
if (o != null)
|
||||
append(elementName, "" + o);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return builder.toString();
|
||||
private static final Pattern P_XML_SPECIAL_CHARACTERS = Pattern.compile("[<>&]");
|
||||
|
||||
private static final String escape(String string) {
|
||||
return P_XML_SPECIAL_CHARACTERS.matcher(string).find()
|
||||
? string.replace("&", "&")
|
||||
.replace("<", "<")
|
||||
.replace(">", ">")
|
||||
: string;
|
||||
}
|
||||
|
||||
public void appendTo(Appendable a) throws IOException {
|
||||
a.append(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user