/** * * @since 2.0.8 */ public static Document getXmlDOMFor(final Reader source) { Validate.notNull(source, "Source cannot be null"); return getDOMFor(source, new XmlNonValidatingSAXTemplateParser(1)); }
public static String getXhtmlFor(final Node node) { return getOutputFor(node, new XhtmlHtml5TemplateWriter(), "XHTML"); }
/** * @deprecated This method has been deprecated in 2.1.3 and is no longer an adequate way to obtain escaped * HTML code. The whole of the escaping mechanism defined on top of these DOMUtils escape/unescape * methods had too many drawbacks and issues, so it was completely replaced by the Unbescape library. * Will be removed in 3.0. */ @Deprecated public static void writeXmlEscaped(final String buffer, final Writer writer, final boolean escapeQuotes) throws IOException { if (buffer == null) { return; } writeXmlEscaped(buffer.toCharArray(), writer, escapeQuotes); }
public static List<Node> extractFragmentByElementAndAttributeValue( final List<Node> rootNodes, final String elementName, final String attributeName, final String attributeValue) { Validate.notNull(rootNodes, "Root node list cannot be null"); // Element name, attribute name and attribute value CAN be null // (in that case, all elements will be searched) final String normalizedElementName = Element.normalizeElementName(elementName); final String normalizedAttributeName = Attribute.normalizeAttributeName(attributeName); final List<Node> fragmentNodes = new ArrayList<Node>(5); for (final Node rootNode : rootNodes) { final List<Node> extraction = extractFragmentFromNode(rootNode, normalizedElementName, normalizedAttributeName, attributeValue); if (extraction != null) { fragmentNodes.addAll(extraction); } } return fragmentNodes; }
writer.write(buffer, off, len); if (isEntityStart(buffer, i)) {
len = 0; } else if (c == ';' && entityStart != -1) { builder.append(unescapeXmlEntity(str, entityStart, entityLen + 1, unescapeQuotes)); entityStart = -1; entityLen = 0;
public List<Node> extractFragment(final Configuration configuration, final List<Node> nodes) { DOMUtils.extractFragmentByElementAndAttributeValue( nodes, this.elementName, this.attributeName, this.attributeValue);
@SuppressWarnings("unchecked") protected ProcessorResult doProcessElement(Arguments arguments, Element element, HttpServletRequest request, HttpServletResponse response, HtmlTable htmlTable) { Map<String, Map<ConfType, Object>> configs = (Map<String, Map<ConfType, Object>>) RequestUtils.getFromRequest( DataTablesDialect.INTERNAL_BEAN_CONFIGS, request); String tableId = ((Element) element.getParent()).getAttributeValue(DataTablesDialect.DIALECT_PREFIX + ":conf"); String uid = element.getAttributeValue(DataTablesDialect.DIALECT_PREFIX + ":uid"); if (configs != null) { if (configs.containsKey(tableId)) { List<ExtraHtml> extraHtmls = (List<ExtraHtml>) configs.get(tableId).get(ConfType.EXTRAHTML); if (extraHtmls != null && !extraHtmls.isEmpty()) { for (ExtraHtml extraHtml : extraHtmls) { if (extraHtml.getUid().equals(uid)) { Element e = DomUtils.findElement((Element) element.getParent(), "div", DataTablesDialect.DIALECT_PREFIX + ":uid", uid); StringBuilder sb = new StringBuilder(); for (Node child : e.getChildren()) { sb.append(DOMUtils.getHtml5For(child).replaceAll("[\n\r]", "").trim()); } extraHtml.setContent(sb.toString()); } } } } else { logger.warn("No configuration was found for the table with id '{}'", tableId); } } return ProcessorResult.ok(); }
for (final Node child : children) { final List<Node> childResult = extractFragmentFromNode( child, normalizedElementName, normalizedAttributeName, attributeValue); if (childResult != null) {
/** * * @since 2.0.8 */ public static Document getHtml5DOMFor(final Reader source) { Validate.notNull(source, "Source cannot be null"); return getDOMFor(source, new XhtmlAndHtml5NonValidatingSAXTemplateParser(1)); }
public static String getXmlFor(final Node node) { return getOutputFor(node, new XmlTemplateWriter(), "XML"); }
/** * @deprecated This method has been deprecated in 2.1.3 and is no longer an adequate way to obtain escaped * HTML code. The whole of the escaping mechanism defined on top of these DOMUtils escape/unescape * methods had too many drawbacks and issues, so it was completely replaced by the Unbescape library. * Will be removed in 3.0. */ @Deprecated public static char[] escapeXml(final char[] ch, final boolean escapeQuotes) throws IOException { if (ch == null) { return null; } for (final char c : ch) { if (c == '&' || c == '<' || c == '>' || (escapeQuotes && (c == '\'' || c == '\"'))) { final CharArrayWriter writer = new CharArrayWriter(); writeXmlEscaped(ch, writer, escapeQuotes); return writer.toCharArray(); } } return ch; }
/** * * @since 2.0.8 */ public static Document getLegacyHTML5DOMFor(final Reader source) { Validate.notNull(source, "Source cannot be null"); return getDOMFor(source, new LegacyHtml5TemplateParser("LEGACYHTML5", 1)); }
public static String getHtml5For(final Node node) { return getOutputFor(node, new XhtmlHtml5TemplateWriter(), "HTML5"); }
/** * @deprecated This method has been deprecated in 2.1.3 and is no longer an adequate way to obtain escaped * HTML code. The whole of the escaping mechanism defined on top of these DOMUtils escape/unescape * methods had too many drawbacks and issues, so it was completely replaced by the Unbescape library. * Will be removed in 3.0. */ @Deprecated public static String escapeXml(final String str, final boolean escapeQuotes) throws IOException { if (str == null) { return null; } final int strLen = str.length(); for (int i = 0; i < strLen; i++) { final char c = str.charAt(i); if (c == '&' || c == '<' || c == '>' || (escapeQuotes && (c == '\'' || c == '\"'))) { final StringWriter writer = new StringWriter(); writeXmlEscaped(str, writer, escapeQuotes); return writer.toString(); } } return str; }
/** * * @since 2.0.8 */ public static Document getXhtmlDOMFor(final Reader source) { Validate.notNull(source, "Source cannot be null"); return getDOMFor(source, new XhtmlAndHtml5NonValidatingSAXTemplateParser(1)); }
templateRepository, document); return getOutputFor(arguments, node, templateWriter);
/** * * @since 2.0.8 */ public static Document getDOMFor(final Reader source, final ITemplateParser parser) { Validate.notNull(source, "Source cannot be null"); Validate.notNull(parser, "Template parser cannot be null"); final Configuration configuration = new Configuration(); configuration.addTemplateResolver(new ClassLoaderTemplateResolver()); configuration.addMessageResolver(new StandardMessageResolver()); configuration.setTemplateModeHandlers(StandardTemplateModeHandlers.ALL_TEMPLATE_MODE_HANDLERS); configuration.initialize(); return getDOMFor(configuration, source, parser); }