本文整理了Java中org.jsoup.nodes.Document.createElement()
方法的一些代码示例,展示了Document.createElement()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Document.createElement()
方法的具体详情如下:
包路径:org.jsoup.nodes.Document
类名称:Document
方法名:createElement
[英]Create a new Element, with this document's base uri. Does not make the new element a child of this document.
[中]使用此文档的基本uri创建新元素。不会使新元素成为此文档的子元素。
代码示例来源:origin: com.vaadin/vaadin-server
/**
* Creates an html tree node corresponding to the given element. Also
* initializes its attributes by calling writeDesign. As a result of the
* writeDesign() call, this method creates the entire subtree rooted at the
* returned Node.
*
* @param childComponent
* The component with state that is written in to the node
* @return An html tree node corresponding to the given component. The tag
* name of the created node is derived from the class name of
* childComponent.
*/
public Element createElement(Component childComponent) {
ComponentMapper componentMapper = Design.getComponentMapper();
String tagName = componentMapper.componentToTag(childComponent, this);
Element newElement = doc.createElement(tagName);
childComponent.writeDesign(newElement, this);
// Handle the local id. Global id and caption should have been taken
// care of by writeDesign.
String localId = componentToLocalId.get(childComponent);
if (localId != null) {
newElement.attr(LOCAL_ID_ATTRIBUTE, localId);
}
return newElement;
}
代码示例来源:origin: com.vaadin/vaadin-server
/**
* Writes the package mappings (prefix -> package name) of this object to
* the specified document.
* <p>
* The prefixes are stored as <meta> tags under <head> in the document.
*
* @param doc
* the Jsoup document tree where the package mappings are written
*/
public void writePackageMappings(Document doc) {
Element head = doc.head();
for (String prefix : getPackagePrefixes()) {
// Only store the prefix-name mapping if it is not a default mapping
// (such as "vaadin" -> "com.vaadin.ui")
if (!VAADIN_PREFIX.equals(prefix) && !VAADIN7_PREFIX.equals(prefix)
&& !LEGACY_PREFIX.equals(prefix)) {
Node newNode = doc.createElement("meta");
newNode.attr("name", "package-mapping");
String prefixToPackageName = prefix + ":" + getPackage(prefix);
newNode.attr("content", prefixToPackageName);
head.appendChild(newNode);
}
}
}
代码示例来源:origin: com.vaadin/vaadin-server
DocumentType docType = new DocumentType("html", "", "", "");
doc.appendChild(docType);
Element html = doc.createElement("html");
doc.appendChild(html);
html.appendChild(doc.createElement("head"));
Element body = doc.createElement("body");
html.appendChild(body);
代码示例来源:origin: org.aperteworkflow/webapi
private void addVersionNumber(Document document) {
Element versionNumber = document.createElement("div")
.attr("id", "versionList")
.attr("class", "process-version");
document.appendChild(versionNumber);
versionNumber.append(description + " v. " + version);
}
代码示例来源:origin: com.haulmont.cuba/cuba-web
protected void includeMetaViewport(String content, BootstrapPageResponse response, Element head) {
Element meta = response.getDocument().createElement("meta");
meta.attr("name", "viewport");
meta.attr("content", content);
head.appendChild(meta);
}
}
代码示例来源:origin: com.haulmont.cuba/cuba-web
protected void includeScript(String src, BootstrapPageResponse response, Element head) {
Element script = response.getDocument().createElement("script");
script.attr("src", src);
head.appendChild(script);
}
代码示例来源:origin: wuman/JReadability
/**
* Get the article title as an H1. Currently just uses document.title, we
* might want to be smarter in the future.
*
* @return
*/
protected Element getArticleTitle() {
Element articleTitle = mDocument.createElement("h1");
articleTitle.html(mDocument.title());
return articleTitle;
}
代码示例来源:origin: org.aperteworkflow/webapi
private void createButton(Element parent, String actionButtonId, String buttonClass, String iconClass,
String messageKey, String descriptionKey, String clickFunction) {
Element buttonNode = parent.ownerDocument().createElement("button")
.attr("class", buttonClass != null ? "btn btn-" + buttonClass : "btn")
.attr("disabled", "true")
.attr("id", actionButtonId)
.attr("data-toggle", "tooltip")
.attr("data-placement", "bottom")
.attr("title", i18Source.getMessage(descriptionKey));
Element buttonIcon = parent.ownerDocument().createElement("span")
.attr("class", iconClass != null ? "glyphicon glyphicon-" + iconClass : "glyphicon");
parent.appendChild(buttonNode);
buttonNode.appendChild(buttonIcon);
buttonNode.appendText(i18Source.getMessage(messageKey));
scriptBuilder.append("$('#").append(actionButtonId).append("').click(function() { ").append(clickFunction).append("('").append(getViewedObjectId()).append("'); });");
scriptBuilder.append("$('#").append(actionButtonId).append("').tooltip();");
}
代码示例来源:origin: jreznot/electron-java-app
@Override
public void modifyBootstrapPage(BootstrapPageResponse response) {
// Obtain electron UI API end point
Element head = response.getDocument().getElementsByTag("head").get(0);
Element script = response.getDocument().createElement("script");
script.attr("type", "text/javascript");
URL jsBridge = AppServlet.class.getResource("/org/strangeway/electronvaadin/resources/electron-bridge.js");
try {
script.text(IOUtils.toString(jsBridge, StandardCharsets.UTF_8));
} catch (IOException e) {
throw new RuntimeException("Unable to load JS bridge", e);
}
head.appendChild(script);
}
}
代码示例来源:origin: basis-technology-corp/Java-readability
private Element changeElementTag(Element e, String newTag) {
Element newElement = document.createElement(newTag);
/* JSoup gives us the live child list, so we need to make a copy. */
List<Node> copyOfChildNodeList = new ArrayList<Node>();
copyOfChildNodeList.addAll(e.childNodes());
for (Node n : copyOfChildNodeList) {
n.remove();
newElement.appendChild(n);
}
e.replaceWith(newElement);
return newElement;
}
代码示例来源:origin: org.aperteworkflow/webapi
private void addClaimActionButton(Element parent) {
String actionButtonId = "action-button-claim";
Element buttonNode = parent.ownerDocument().createElement("button")
.attr("class", "btn btn-warning")
.attr("disabled", "true")
.attr("id", actionButtonId);
parent.appendChild(buttonNode);
Element cancelButtonIcon = parent.ownerDocument().createElement("span")
.attr("class", "glyphicon glyphicon-download");
parent.appendChild(buttonNode);
buttonNode.appendChild(cancelButtonIcon);
buttonNode.appendText(i18Source.getMessage("button.claim"));
Long processStateConfigurationId = task.getCurrentProcessStateConfiguration().getId();
scriptBuilder.append("$('#").append(actionButtonId)
.append("').click(function() { claimTaskFromQueue('#action-button-claim','null', '")
.append(processStateConfigurationId).append("','")
.append(task.getInternalTaskId())
.append("'); });")
.append("$('#").append(actionButtonId)
.append("').tooltip({placement: 'bottom', title: '").append(i18Source.getMessage("button.claim.descrition")).append("'});");
}
代码示例来源:origin: uk.gov.dstl.baleen/baleen-collectionreaders
run = document.createElement("p");
代码示例来源:origin: com.vaadin.addon/vaadin-touchkit-agpl
@Override
public void modifyBootstrapPage(BootstrapPageResponse response) {
Document document = response.getDocument();
Element head = document.getElementsByTag("head").get(0);
for (ApplicationIcon icon : applicationIcon) {
// <link rel="apple-touch-icon" sizes="114x114"
// href="touch-icon-iphone4.png" />
Element iconEl = document.createElement("link");
iconEl.attr("rel", "apple-touch-icon");
String sizes = icon.getSizes();
if (sizes != null) {
iconEl.attr("sizes", sizes);
}
iconEl.attr("href", icon.getHref());
head.appendChild(iconEl);
}
}
代码示例来源:origin: dstl/baleen
run = document.createElement("p");
代码示例来源:origin: org.aperteworkflow/webapi
public StringBuilder build() throws Exception {
final StringBuilder stringBuilder = new StringBuilder(8 * 1024);
scriptBuilder.append("<script type=\"text/javascript\">");
final Document document = Jsoup.parse("");
if (!hasUserPriviledgesToViewTask()) {
final Element widgetsNode = document.createElement("div")
.attr("role", "alert")
.attr("class", "alert alert-warning");
widgetsNode.text(i18Source.getMessage("task.noright.to.view"));
document.appendChild(widgetsNode);
stringBuilder.append(document.toString());
return stringBuilder;
}
if (showGenericButtons())
buildActionButtons(document);
final Element widgetsNode = document.createElement("div")
.attr("id", getVaadinWidgetsHtmlId())
.attr("class", "vaadin-widgets-view");
document.appendChild(widgetsNode);
buildWidgets(document, widgetsNode);
buildAdditionalData(document);
stringBuilder.append(document.toString());
scriptBuilder.append("vaadinWidgetsCount = ").append(vaadinWidgetsCount).append(';');
scriptBuilder.append("</script>");
stringBuilder.append(scriptBuilder);
return stringBuilder;
}
代码示例来源:origin: io.committed.krill/krill
final Element e = document.createElement("details").addClass("footnote")
.text(matcher.group("content"));
p.appendChild(e);
代码示例来源:origin: org.aperteworkflow/webapi
/**
* Add actions buttons to the output document.
*/
protected void buildActionButtons(final Document document) {
Element actionsNode = document.createElement("div")
//.attr("id", "actions-list")
.attr("id", getActionsListHtmlId())
.attr("class", "actions-view")
.addClass("fixed-element-action-buttons");
document.appendChild(actionsNode);
Element genericActionButtons = document.createElement("div")
.attr("id", getActionsGenericListHtmlId())
.attr("class", "btn-group pull-left actions-generic-view");
Element specificActionButtons = document.createElement("div")
.attr("id", getActionsSpecificListHtmlId())
.attr("class", "btn-group pull-right actions-process-view");
actionsNode.appendChild(genericActionButtons);
actionsNode.appendChild(specificActionButtons);
document.appendElement("div").addClass("fixed-element-anchor-action-buttons");
/* Check if the viewed object is in a terminal state */
buildGenericActionButtons(genericActionButtons);
if (!isViewedObjectClosed()) {
buildSpecificActionButtons(specificActionButtons);
}
}
代码示例来源:origin: io.zipkin.java/zipkin-autoconfigure-ui
@Bean
@Lazy
String processedIndexHtml() throws IOException {
String baseTagValue = "/".equals(ui.getBasepath()) ? "/" : ui.getBasepath() + "/";
Document soup;
try (InputStream is = indexHtml.getInputStream()) {
soup = Jsoup.parse(is, null, baseTagValue);
}
if (soup.head().getElementsByTag("base").isEmpty()) {
soup.head().appendChild(
soup.createElement("base")
);
}
soup.head().getElementsByTag("base").attr("href", baseTagValue);
return soup.html();
}
代码示例来源:origin: com.vaadin.addon/vaadin-touchkit-agpl
doctype.replaceWith(html5doc);
Element element = document.createElement("meta");
element.attr("name", "viewport");
StringBuilder content = new StringBuilder();
element = document.createElement("meta");
element.attr("name", "msapplication-tap-highlight");
element.attr("content", "no");
代码示例来源:origin: com.vaadin/flow-server
.createElement(element.getTag());
if (element.hasProperty("innerHTML")) {
target.html((String) element.getPropertyRaw("innerHTML"));
内容来源于网络,如有侵权,请联系作者删除!