public String toString() { return outerHtml(); }
private String getValue(Element element) { if (attrName == null) { return element.outerHtml(); } else if ("innerHtml".equalsIgnoreCase(attrName)) { return element.html(); } else if ("text".equalsIgnoreCase(attrName)) { return getText(element); } else if ("allText".equalsIgnoreCase(attrName)) { return element.text(); } else { return element.attr(attrName); } }
/** * Get the combined outer HTML of all matched elements. * @return string of all element's outer HTML. * @see #text() * @see #html() */ public String outerHtml() { StringBuilder sb = new StringBuilder(); for (Element element : this) { if (sb.length() != 0) sb.append("\n"); sb.append(element.outerHtml()); } return sb.toString(); }
public List<String> $list(String selector) { List<String> list = new ArrayList<String>(); Elements elements = $(selector); if (elements != null) { for (Element ele : elements) { list.add(ele.outerHtml()); } } return list; }
@Signature public String outerHtml() { return getWrappedObject().outerHtml(); }
} else if (field.isAnnotationPresent(Html.class)) {// @Html Html html = field.getAnnotation(Html.class); list.add(html.outer() ? el.outerHtml() : el.html()); } else {// Other list.add(el.html());
@Override public void run(final Config conf) throws Exception { String input = get("input"); if (input == null) { throw new IllegalArgumentException("Required option 'svg-symbol.input' not present"); } Path basedir = Paths.get(get("basedir").toString()); Path dir = basedir.resolve(input); List<CharSequence> cssout = new ArrayList<>(); Element svg = new Element(Tag.valueOf("svg"), ""); attrs("svg", "output").forEach((n, v) -> svg.attr(n, v.toString())); files(dir, file -> { log.debug("{}", file); String id = get("id.prefix") + file.getFileName().toString().replace(".svg", "") + get("id.suffix"); Tuple<Element, Element> rewrite = symbol(file, id); svg.appendChild(rewrite._2); cssout.add(css(id, rewrite._1)); }); write(basedir.resolve(svgPath()), ImmutableList.of(svg.outerHtml())); write(basedir.resolve(cssPath()), cssout); }
Document doc = Jsoup.connect("http://example.com") Element link = doc.select("a").first(); String text = doc.body().text(); // "An example link" String linkHref = link.attr("href"); // "http://example.com/" String linkText = link.text(); // "example"" String linkOuterH = link.outerHtml(); // "<a href="http://example.com"><b>example</b></a>" String linkInnerH = link.html(); // "<b>example</b>"
String id = elementUserManaged.attr("id"); if (StringUtils.isNotBlank(id)) { String code = elementUserManaged.outerHtml(); structureUserManaged.put(id, code);
private Document mergeCreateDetailsView(String templateName, Document loadExistingDoc, ViewContext ctx, EntityItem entityItem, DetailEntityItem detail) { Element elementDetail = loadExistingDoc.getElementById(detail.getEntityItemId()); if (elementDetail != null && elementDetail.hasAttr("data-z") && elementDetail.attr("data-z").equals("user-managed")) { detail.setUserManaged(true); detail.setCodeManaged(elementDetail.outerHtml()); ctx.addExtraParameter("detail", detail); } ctx.addExtraParameter("userManagedComponents", mergeStructure(loadExistingDoc)); return process(templateName, ctx); }
@Override public Document mergeMenu(String templateName, Document loadExistingDoc, ViewContext<ThymeleafMetadata> ctx, List<MenuEntry> menuEntries) { for (MenuEntry menuEntry : menuEntries) { // Get field code if data-z attribute value is equals to // user-managed Element elementMenu = loadExistingDoc.getElementById(menuEntry.getId().concat("-entry")); if (elementMenu != null && elementMenu.hasAttr("data-z") && elementMenu.attr("data-z").equals("user-managed")) { menuEntry.setUserManaged(true); menuEntry.setCodeManaged(elementMenu.outerHtml()); } } ctx.addExtraParameter("userManagedComponents", mergeStructure(loadExistingDoc)); ctx.addExtraParameter("menuEntries", menuEntries); Document newDoc = process(templateName, ctx); return newDoc; }
@Override public Document mergeListDeleteModalView(String templateName, Document loadExistingDoc, ViewContext<ThymeleafMetadata> ctx, EntityItem entity, List<FieldItem> fields) { // Get field code if data-z attribute value is equals to user-managed Element elementField = loadExistingDoc.getElementById(entity.getEntityItemId().concat("-table")); if (elementField != null && elementField.hasAttr("data-z") && elementField.attr("data-z").equals("user-managed")) { entity.setUserManaged(true); entity.setCodeManaged(elementField.outerHtml()); } ctx.addExtraParameter("userManagedComponents", mergeStructure(loadExistingDoc)); ctx.addExtraParameter("entity", entity); ctx.addExtraParameter("fields", fields); Document newDoc = process(templateName, ctx); return newDoc; }
@Override public Document mergeListDeleteModalDetailView(String templateName, Document loadExistingDoc, ViewContext<ThymeleafMetadata> ctx, EntityItem entity, List<FieldItem> fields) { // Get field code if data-z attribute value is equals to user-managed Element elementField = loadExistingDoc.getElementById(entity.getEntityItemId().concat("-table")); if (elementField != null && elementField.hasAttr("data-z") && elementField.attr("data-z").equals("user-managed")) { entity.setUserManaged(true); entity.setCodeManaged(elementField.outerHtml()); } ctx.addExtraParameter("userManagedComponents", mergeStructure(loadExistingDoc)); ctx.addExtraParameter("entity", entity); ctx.addExtraParameter("fields", fields); Document newDoc = process(templateName, ctx); return newDoc; }
@Override public Document mergeListDeleteModalBatchView(String templateName, Document loadExistingDoc, ViewContext<ThymeleafMetadata> ctx, EntityItem entity, List<FieldItem> fields) { // Get field code if data-z attribute value is equals to user-managed Element elementField = loadExistingDoc.getElementById(entity.getEntityItemId().concat("-table")); if (elementField != null && elementField.hasAttr("data-z") && elementField.attr("data-z").equals("user-managed")) { entity.setUserManaged(true); entity.setCodeManaged(elementField.outerHtml()); } ctx.addExtraParameter("userManagedComponents", mergeStructure(loadExistingDoc)); ctx.addExtraParameter("entity", entity); ctx.addExtraParameter("fields", fields); Document newDoc = process(templateName, ctx); return newDoc; }
@Override public Document mergeListDeleteModalBatchDetailView(String templateName, Document loadExistingDoc, ViewContext<ThymeleafMetadata> ctx, EntityItem entity, List<FieldItem> fields) { // Get field code if data-z attribute value is equals to user-managed Element elementField = loadExistingDoc.getElementById(entity.getEntityItemId().concat("-table")); if (elementField != null && elementField.hasAttr("data-z") && elementField.attr("data-z").equals("user-managed")) { entity.setUserManaged(true); entity.setCodeManaged(elementField.outerHtml()); } ctx.addExtraParameter("userManagedComponents", mergeStructure(loadExistingDoc)); ctx.addExtraParameter("entity", entity); ctx.addExtraParameter("fields", fields); Document newDoc = process(templateName, ctx); return newDoc; }
&& elementField.attr("data-z").equals("user-managed")) { entity.setUserManaged(true); entity.setCodeManaged(elementField.outerHtml()); && elementDetail.attr("data-z").equals("user-managed")) { detail.setUserManaged(true); detail.setCodeManaged(elementDetail.outerHtml()); if (elementTabCodeDetailField != null && elementTabCodeDetailField.hasAttr("data-z") && elementTabCodeDetailField.attr("data-z").equals("user-managed")) { detail.setTabLinkCode(elementTabCodeDetailField.outerHtml());
@Override public Document merge(String templateName, Document loadExistingDoc, ViewContext<ThymeleafMetadata> ctx, List<FieldItem> fields) { for (FieldItem field : fields) { // Get field code if data-z attribute value is equals to // user-managed Element elementField = loadExistingDoc.getElementById(field.getFieldId()); if (elementField != null && elementField.hasAttr("data-z") && elementField.attr("data-z").equals("user-managed")) { field.setUserManaged(true); field.setCodeManaged(elementField.outerHtml()); } } ctx.addExtraParameter("userManagedComponents", mergeStructure(loadExistingDoc)); ctx.addExtraParameter("fields", fields); Document newDoc = process(templateName, ctx); return newDoc; }
private Document mergeDetailsCompositionView(String templateName, Document loadExistingDoc, ViewContext ctx, EntityItem entityItem, DetailEntityItem detail, List<FieldItem> fields) { for (FieldItem field : fields) { // Get field code if data-z attribute value is equals to // user-managed Element elementField = loadExistingDoc.getElementById(field.getFieldId()); if (elementField != null && elementField.hasAttr("data-z") && elementField.attr("data-z").equals("user-managed")) { field.setUserManaged(true); field.setCodeManaged(elementField.outerHtml()); } else { field.setUserManaged(false); field.setCodeManaged(""); } } ctx.addExtraParameter("fields", fields); ctx.addExtraParameter("userManagedComponents", mergeStructure(loadExistingDoc)); return process(templateName, ctx); }
protected String getSource(Element element) { if (attribute == null) { return element.outerHtml(); } else { String attr = element.attr(attribute); Validate.notNull(attr, "Attribute " + attribute + " of " + element + " is not exist!"); return attr; } }
@Override public XValue call(Scope scope) { List<String> res = new LinkedList<>(); for (Element e:scope.context()){ res.add(e.outerHtml()); } return XValue.create(res); } }