private void printITSExtStringAttribute (String value, String attrName, StringBuilder output) { if ( value != null ) { output.append((isHTML5 ? " data-" : ITSXLF_PREF)+attrName+"=\""+Util.escapeToXML(value, 3, false, encoder)+"\""); } }
private static String escape (String text) { text = text.replace("\n", "\\n"); text = text.replace("\t", "\\t"); return Util.escapeToXML(text, 3, false, null); }
private String outputRefOrValue (String partialName, String value, boolean useHTML5Notation) { if ( value.startsWith(GenericAnnotationType.REF_PREFIX) ) { value = value.substring(GenericAnnotationType.REF_PREFIX.length()); partialName = partialName + (useHTML5Notation ? "-ref" : "Ref"); } return partialName+"=\""+Util.escapeToXML(value, 3, false, encoder)+"\""; }
private void printITSStringAttribute (String value, String attrName, StringBuilder output) { if ( value != null ) { String ref = ""; if ( value.startsWith(REF_PREFIX) ) { ref = (isHTML5 ? "-ref" : "Ref"); value = value.substring(REF_PREFIX.length()); } output.append(" "+prefix+attrName+ref+"=\""+Util.escapeToXML(value, 3, false, encoder)+"\""); } }
/** * Writes an attribute and its associated value. You must use * {@link #writeStartElement(String)} just before. * @param name the name of the attribute. * @param value the value of the attribute. */ public void writeAttributeString (String name, String value) { write(" " + name + "=\"" + Util.escapeToXML(value, 3, false, null) + "\""); }
public String toXML() { StringBuilder sb = new StringBuilder(); sb.append("<tool"); sb.append(" tool-id=\"") .append(Util.escapeToXML(id, 1, false, null)).append("\""); sb.append(" tool-name=\"") .append(Util.escapeToXML(name, 1, false, null)).append("\""); if (version != null) { sb.append(" tool-version=\"") .append(Util.escapeToXML(version, 1, false, null)).append("\""); } if (company != null) { sb.append(" tool-company=\"") .append(Util.escapeToXML(company, 1, false, null)).append("\""); } sb.append(">"); sb.append(skel); sb.append("</tool>"); return sb.toString(); }
private void procCharacters(Characters chars) { String escaped = Util.escapeToXML( chars.getData().replace("\n", lineBreak), 0, true, null); skel.append(escaped); }
public String buildStartTag (Element elem) { StringBuilder sb = new StringBuilder("<"+elem.getNodeName()); NamedNodeMap attrNames = elem.getAttributes(); for ( int i=0; i<attrNames.getLength(); i++ ) { Attr attr = (Attr)attrNames.item(i); sb.append(" " + attr.getName() + "=\""); sb.append(Util.escapeToXML(attr.getValue(), 3, false, null)); sb.append("\""); } // Make it an empty element if possible if ( elem.hasChildNodes() ) { sb.append(">"); } else { sb.append("/>"); } return sb.toString(); }
public String buildStartTag (Element elem) { StringBuilder sb = new StringBuilder("<"+elem.getNodeName()); NamedNodeMap attrNames = elem.getAttributes(); for ( int i=0; i<attrNames.getLength(); i++ ) { Attr attr = (Attr)attrNames.item(i); sb.append(" " + attr.getName() + "=\""); sb.append(Util.escapeToXML(attr.getValue(), 3, false, null)); sb.append("\""); } // Make it an empty element if possible if ( elem.hasChildNodes() ) { sb.append(">"); } else { sb.append("/>"); } return sb.toString(); }
sb.append("<phase"); sb.append(" phase-name=\"") .append(Util.escapeToXML(phaseName, 1, false, null)).append("\""); sb.append(" process-name=\"") .append(Util.escapeToXML(processName, 1, false, null)).append("\""); if (companyName != null) { sb.append(" company-name=\"") .append(Util.escapeToXML(companyName, 1, false, null)).append("\""); .append(Util.escapeToXML(toolId, 1, false, null)).append("\""); .append(Util.escapeToXML(jobId, 1, false, null)).append("\""); .append(Util.escapeToXML(contactName, 1, false, null)).append("\""); .append(Util.escapeToXML(contactEmail, 1, false, null)).append("\""); .append(Util.escapeToXML(contactPhone, 1, false, null)).append("\"");
/** * Copy a parsed attribute to the provided buffer, escaping the value. The * attribute will be preceded by a whitespace character. * * @param sb target buffer * @param reader XMLStreamReader * @param attrIndex the index of the attribute to copy from the reader * @param lineBreak for escaping purposes * @param escapeGT whether or not to escape GT */ static void copyAttributeToBuffer(StringBuilder sb, XMLStreamReader reader, int attrIndex, String lineBreak, boolean escapeGT) { String prefix = reader.getAttributePrefix(attrIndex); sb.append(" "); if (prefix != null && !"".equals(prefix)) { sb.append(prefix).append(":"); } sb.append(reader.getAttributeLocalName(attrIndex)); sb.append("=\""); sb.append(Util.escapeToXML(reader.getAttributeValue(attrIndex).replace("\n", lineBreak), 3, escapeGT, null)); sb.append('\"'); }
/** * Writes a string. The text is automatically escaped. * @param text the text to output. */ public void writeString (String text) { closeStartTag(); appendRawXML(Util.escapeToXML(text, 0, false, null)); }
/** * creates a ctype value for the given {@link Code} object and the given {@link TAG}. * * @param code the code object * @param tag the xliff TAG * @return a ctype value for the given {@link Code} object and the given {@link TAG}. */ private String createCtype(Code code, TAG tag) { String result = ""; String codeType = code.getType(); if (!isValidCtype(tag, codeType)) { result = EXTENDED_CODE_TYPE_PREFIX; } if (codeType == null || codeType.isEmpty()) { result += "empty"; } else { // escape xml result += Util.escapeToXML(codeType, 1, false, null); // replace blanks in ctype values to underscores result = result.replaceAll(" ", "_"); } return result; }
tmp.append(Util.escapeToXML(attr.getNodeValue(), 3, false, null) + "\""); tmp.append(Util.escapeToXML(attr.getNodeValue(), 3, false, null) + "\"");
sb.append(Util.escapeToXML(displayText, 1, false, null)); sb.append("\""); String merged = code.getMergedData(); merged = Util.escapeWhitespaceForXML(merged); sb.append(Util.escapeToXML(merged, 1, false, null)); sb.append("\"");
for ( Segment seg : textCont.getSegments() ) { writer.write("<p>"); //$NON-NLS-1$ writer.write(Util.escapeToXML(sampleOutput.setContent(seg.text).toString(true), 0, false, null)); writer.write("</p>"); //$NON-NLS-1$
/** * Writes an element and its content. * @param name the name of the element to write. * @param content the content to enclose inside this element. */ public void writeElementString (String name, String content) { closeStartTag(); write("<" + name + ">"); write(Util.escapeToXML(content, 0, false, null)); write("</" + name + ">"); }
if ( strVal != null ) sb.append(outputRefOrValue(" revTool", strVal, false)); strVal = ann.getString(GenericAnnotationType.PROV_PROVREF); if ( strVal != null ) sb.append(" provRef=\"" + Util.escapeToXML(strVal, 3, false, encoder) + "\""); sb.append("/>");
String strVal = iann.getCodes(); if (strVal != null) { output.append(" okp:lqiCodes=\"" + Util.escapeToXML(strVal, 3, false, encoder) + "\""); output.append(" okp:lqiSegId=\"" + Util.escapeToXML(strVal, 3, false, encoder) + "\"");
case DOCUMENT_PART: DocumentPart dp = e.getDocumentPart(); dp.setSkeleton(new GenericSkeleton(Util.escapeToXML(dp.getSkeleton().toString(), 0, true, null))); break; case TEXT_UNIT: for (GenericSkeletonPart p : s.getParts()) { if (p.getParent() == null) { p.setData(Util.escapeToXML(p.getData().toString(), 0, true, null)); c.setData(Util.escapeToXML(c.getData(), 0, true, null)); if (c.hasOuterData()) { c.setOuterData(Util.escapeToXML(c.getOuterData(), 0, true, null)); TextFragment f = new TextFragment(Util.escapeToXML(tu.getSource().getFirstContent().getCodedText(), 0, true, null), codes); tu.setSourceContent(f); break;