Java Code Examples for org.apache.commons.lang3.StringEscapeUtils#escapeXml()
The following examples show how to use
org.apache.commons.lang3.StringEscapeUtils#escapeXml() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TrpTeiStringBuilder.java From TranskribusCore with GNU General Public License v3.0 | 6 votes |
void writeEditorialDeclaration(SebisStringBuilder sb) { if (trpDoc.getEdDeclList()==null || trpDoc.getEdDeclList().isEmpty()) return; sb.incIndent(); sb.addLine("<encodingDesc>"); sb.incIndent(); sb.addLine("<editorialDecl>"); sb.incIndent(); for (EdFeature f : trpDoc.getEdDeclList()) { if (f.getSelectedOption()!=null) { String str = f.getTitle()+" ("+f.getDescription()+"): "+f.getSelectedOption().getText(); String escapedstr = StringEscapeUtils.escapeXml(str); sb.addLine("<p>"+escapedstr+"</p>"); } } sb.decIndent(); sb.addLine("</editorialDecl>"); sb.decIndent(); sb.addLine("</encodingDesc>"); sb.decIndent(); }
Example 2
Source File: TrpTeiStringBuilder.java From TranskribusCore with GNU General Public License v3.0 | 6 votes |
/** * Escapes the given shape text for XML and adjusts offset/length values of given tags accordingly */ String escapeShapeText(String text, List<CustomTag> tags) { String escapedText=""; for (int i=0; i<text.length(); ++i) { char c = text.charAt(i); String escaped = StringEscapeUtils.escapeXml(""+c); int indexOfChar = escapedText.length(); escapedText += escaped; correctTagOffsetsForEscapedString(indexOfChar, escaped, tags); // // adapt tag indices for the additional characters that may have been inserted due to escape // if (escaped.length() > 1) { // logger.trace("escaped = "+escaped+" length = "+escaped.length()); // correctTagOffsetsForTagInsertion(insertOffset, escaped.length(), tags); // } } return escapedText; }
Example 3
Source File: CssSyntaxTagUtil.java From TranskribusCore with GNU General Public License v3.0 | 5 votes |
/** * Escapes the given shape text for XML and adjusts offset/length values of given tags accordingly */ public static String escapeShapeText(String text, List<CssSyntaxTag> tags) { String escapedText=""; for (int i=0; i<text.length(); ++i) { char c = text.charAt(i); String escaped = StringEscapeUtils.escapeXml(""+c); int indexOfChar = escapedText.length(); escapedText += escaped; correctTagOffsetsForEscapedString(indexOfChar, escaped, tags); } return escapedText; }
Example 4
Source File: TrpTeiStringBuilder.java From TranskribusCore with GNU General Public License v3.0 | 5 votes |
String createTagEnd(CustomTag t) { String te=""; if (t instanceof TextStyleTag) { te = "</hi>"; } else if (t instanceof AbbrevTag) { te = "</abbr></choice>"; } else if (t instanceof PersonTag) { te = "</persName>"; } else if (t instanceof PlaceTag) { te = "</placeName>"; } else if (t instanceof OrganizationTag) { te = "</orgName>"; } else if (t instanceof SpeechTag) { te = "</sp>"; } else if (t instanceof GapTag) { te = ""; } //no comment element in TEI - we use note instead else if (t instanceof CommentTag){ CommentTag ct = (CommentTag) t; te = "<note>"; if (!StringUtils.isEmpty(ct.getComment())) { te += StringEscapeUtils.escapeXml(ct.getComment()); } te += "</note>"; } else { te = "</"+t.getTagName()+">"; } return te; }
Example 5
Source File: MlMessageParser.java From symphony-java-client with Apache License 2.0 | 5 votes |
/** * Experimental - will attempt to escape all text within xml elements * @param xml full xml * @return escaped xml string */ public static String escapeAllXml(String xml) { // Match the pattern <something>text</something> Pattern xmlCleanerPattern = Pattern.compile("(<[^/<>]*>)([^<>]*)(</[^<>]*>)"); StringBuilder xmlStringBuilder = new StringBuilder(); Matcher matcher = xmlCleanerPattern.matcher(xml); int lastEnd = 0; while (matcher.find()) { // Include any non-matching text between this result and the previous result if (matcher.start() > lastEnd) { xmlStringBuilder.append(xml.substring(lastEnd, matcher.start())); } lastEnd = matcher.end(); // Sanitise the characters inside the tags and append the sanitised version String cleanText = StringEscapeUtils.escapeXml(matcher.group(2)); xmlStringBuilder.append(matcher.group(1)).append(cleanText).append(matcher.group(3)); } // Include any leftover text after the last result xmlStringBuilder.append(xml.substring(lastEnd)); return xmlStringBuilder.toString(); }
Example 6
Source File: Encodes.java From dubai with MIT License | 4 votes |
/** * Xml 转码. */ public static String escapeXml(String xml) { return StringEscapeUtils.escapeXml(xml); }
Example 7
Source File: EncryptUtils.java From product-recommendation-system with MIT License | 4 votes |
/** * Xml 转码. */ public static String escapeXml(String xml) { return StringEscapeUtils.escapeXml(xml); }
Example 8
Source File: NeutralSchemaXMLStringWriter.java From secure-data-service with Apache License 2.0 | 4 votes |
private String escape(String input) { return StringEscapeUtils.escapeXml(input); }
Example 9
Source File: Encodes.java From MultimediaDesktop with Apache License 2.0 | 4 votes |
/** * Xml 转码. */ public static String escapeXml(String xml) { return StringEscapeUtils.escapeXml(xml); }
Example 10
Source File: Encodes.java From jee-universal-bms with Apache License 2.0 | 4 votes |
/** * Xml 转码. */ @SuppressWarnings("deprecation") public static String escapeXml(String xml) { return StringEscapeUtils.escapeXml(xml); }
Example 11
Source File: Encodes.java From spring-boot-quickstart with Apache License 2.0 | 4 votes |
/** * Xml 转码. */ public static String escapeXml(String xml) { return StringEscapeUtils.escapeXml(xml); }
Example 12
Source File: Encodes.java From dpCms with Apache License 2.0 | 4 votes |
/** * Xml 转码. */ public static String escapeXml(String xml) { return StringEscapeUtils.escapeXml(xml); }
Example 13
Source File: EncodeUtils.java From base-framework with Apache License 2.0 | 4 votes |
/** * Xml 转码. */ public static String escapeXml(String xml) { return StringEscapeUtils.escapeXml(xml); }
Example 14
Source File: UiUtils.java From pgptool with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("deprecation") public static String envelopeStringIntoHtml(String text) { return "<html><body>" + StringEscapeUtils.escapeXml(text) + "</body></html>"; }
Example 15
Source File: EscapeXMLAttributes.java From levelup-java-examples with Apache License 2.0 | 4 votes |
@Test public void escape_xml_with_apache_commons () { String escapedXML = StringEscapeUtils.escapeXml(XML_TO_ESCAPE); assertEquals(ESCAPED_XML, escapedXML); }
Example 16
Source File: Encodes.java From opencron with Apache License 2.0 | 4 votes |
/** * Xml 转码. */ public static String escapeXml(String xml) { return StringEscapeUtils.escapeXml(xml); }
Example 17
Source File: DigestUtils.java From JobX with Apache License 2.0 | 4 votes |
/** * Xml 转码. */ public static String escapeXml(String xml) { return StringEscapeUtils.escapeXml(xml); }
Example 18
Source File: ReviewUtil.java From shepher with Apache License 2.0 | 4 votes |
public static String generateSummary(String content) { String summary = StringEscapeUtils.escapeXml(content); summary = StringUtils.substring(summary, 0, 50); return summary; }
Example 19
Source File: SymMessage.java From symphony-java-client with Apache License 2.0 | 3 votes |
public void setMessageText(ApiVersion apiVersion, String text) { //Lets make sure we comply with XML text = StringEscapeUtils.escapeXml(text); if (apiVersion != null && !apiVersion.equals(ApiVersion.V2)) { setMessage(MLTypes.START_PML + text + MLTypes.END_PML); } else { setMessageType("MESSAGEML"); setMessage(MLTypes.START_ML + text + MLTypes.END_ML); } }
Example 20
Source File: SpdxLicenseTemplateHelper.java From tools with Apache License 2.0 | 2 votes |
/** * Escapes and formats text * @param text unformatted text * @param inParagraph true if inside a paragraph tag * @return */ public static String formatEscapeHTML(String text, boolean inParagraph) { String retval = StringEscapeUtils.escapeXml(text); return addHtmlFormatting(retval, inParagraph); }