Java Utililty Methods XML Quote

List of utility methods to do XML Quote

  1. HOME
  2. Java
  3. X
  4. XML Quote

Description

The list of methods to do XML Quote are organized into topic(s).

Method

String quoteXML(String string)
Escapes specified string (that is, '<' is replaced by "<;", '&' is replaced by "&", etc) then quotes the escaped string.
StringBuffer quoted = new StringBuffer();
quoted.append('\"');
escapeXML(string, quoted);
quoted.append('\"');
return quoted.toString();
String quoteXML(String string)
Quotes XML special characters and characters above 127 in the specified string.
StringBuilder buffer = new StringBuilder();
for (char c : string.toCharArray()) {
 if (c == '<')
 buffer.append("<");
 else if (c == '>')
 buffer.append(">");
 else if (c == '&')
 buffer.append("&");
...
String quoteXML(String xmlFragment)
A convenience method that allows for XML fragments to be stored in larger XML documents without these fragments interfering with the containing document.
if (!xmlFragment.startsWith(XML_QUOTE_PREFIX)) {
 return (XML_QUOTE_PREFIX + xmlFragment + XML_QUOTE_SUFFIX);
return xmlFragment;
String quoteXmlContent(String x)
Replace special characters with entities for XML attributes.
return replace(x, xmlInC, xmlOutC);
String quoteXMLValue(final Object o)
Convert the object into XML safe string.
if (o == null) {
 return null;
StringBuilder input = new StringBuilder(o.toString());
StringBuilder output = new StringBuilder(input.length());
int seqStart = 0;
int seqEnd = 0;
for (int count = 0; count < input.length(); count++) {
...
String quoteXMLValue(Object o)
Convert the object into XML safe string
if (o == null) {
 return null;
String s = o.toString();
StringBuilder str = new StringBuilder(s.length() * 5 / 4);
int seqStart = 0;
int seqEnd = 0;
for (int count = 0; count < s.length(); count++) {
...


AltStyle によって変換されたページ (->オリジナル) /