本文整理了Java中org.joox.Match.document()
方法的一些代码示例,展示了Match.document()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Match.document()
方法的具体详情如下:
包路径:org.joox.Match
类名称:Match
方法名:document
[英]Get the underlying document of the set of matched elements.
This will also return a document if there are no elements in the set of matched elements, either because a new document has been created previously, or the set of matched elements has been reduced to an empty set.
[中]获取匹配元素集的基础文档。
如果匹配的元素集中没有元素,这也会返回一个文档,原因可能是之前创建了一个新文档,或者匹配的元素集已缩减为一个空集。
代码示例来源:origin: io.teecube.t3/t3-site-enhancer
private void fixAutoclosingElements(Document domDocument) {
try {
Match document = JOOX.$(domDocument);
Match lists = document.xpath(autoclosingElements).filter(new Filter() {
@Override
public boolean filter(Context context) {
return (context.element().getFirstChild() == null); // with no child element (so autoclosing)
}
});
for (org.w3c.dom.Element element : lists) {
if ("script".equals(element.getNodeName())) {
element.appendChild(document.document().createTextNode("// preserve auto-closing elements"));
} else {
element.appendChild(document.document().createComment("preserve auto-closing elements"));
}
}
} catch (Exception e) {
// nothing to do
}
}
代码示例来源:origin: io.teecube.t3/t3-site-enhancer
private void fixLinks(File htmlFile) throws Exception {
Match document = JOOX.$(htmlFile);
Match lists = document.xpath("//a");
for (org.w3c.dom.Element element : lists) {
Attr href = element.getAttributeNode("href");
if (href != null) {
String value = href.getValue();
if (value != null) {
href.setValue(value.replaceAll("(?<!(http:|https:))[//]+", "/"));
}
}
}
printDocument(document.document(), htmlFile);
}
代码示例来源:origin: windup/windup
document = $(is).document();
代码示例来源:origin: org.jboss.windup.legacy.application/grapher
public void writeGraph(final OutputStream os) throws IOException {
// read in the html template resource.
InputStream is = this.getClass().getClassLoader().getResourceAsStream("vizjs/HtmlTemplate.html");
String result;
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
writer.writeGraph(baos);
result = baos.toString();
}
if(LOG.isDebugEnabled()) {
LOG.debug("DOT: "+result);
}
// read the document.
Document document;
try {
document = $(is).document();
// append in the gexf.
$(document).find("#dot-source").append(result);
writeDocument(document, os);
} catch (SAXException e) {
throw new IOException("Exception loading document.", e);
}
}
代码示例来源:origin: org.jboss.windup/windup-grapher
public void writeGraph(final OutputStream os) throws IOException {
// read in the html template resource.
InputStream is = this.getClass().getClassLoader().getResourceAsStream("vizjs/HtmlTemplate.html");
String result;
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
writer.writeGraph(baos);
result = baos.toString();
}
if(LOG.isDebugEnabled()) {
LOG.debug("DOT: "+result);
}
// read the document.
Document document;
try {
document = $(is).document();
// append in the gexf.
$(document).find("#dot-source").append(result);
writeDocument(document, os);
} catch (SAXException e) {
throw new IOException("Exception loading document.", e);
}
}
代码示例来源:origin: org.jboss.windup.legacy.application/grapher
public void writeGraph(final OutputStream os) throws IOException {
// read in the html template resource.
InputStream is = this.getClass().getClassLoader().getResourceAsStream("sigmajs/HtmlTemplate.html");
String result = null;
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
gexfWriter.writeGraph(baos);
result = baos.toString();
}
if(LOG.isDebugEnabled()) {
LOG.debug("GEXF: "+result);
}
// read the document.
Document document;
try {
document = $(is).document();
// append in the gexf.
$(document).find("#gexf-source").append(result);
writeDocument(document, os);
} catch (SAXException e) {
throw new IOException("Exception loading document.", e);
}
}
代码示例来源:origin: org.jboss.windup.reporting/windup-reporting-impl
try
document = $(is).document();
代码示例来源:origin: org.jboss.windup.legacy.application/grapher
public void writeGraph(final OutputStream os) throws IOException {
// read in the html template resource.
InputStream is = this.getClass().getClassLoader().getResourceAsStream("dagred3/HtmlTemplate.html");
String result;
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
writer.writeGraph(baos);
result = baos.toString();
}
if(LOG.isDebugEnabled()) {
LOG.debug("Graphlib: "+result);
}
// read the document.
Document document;
try {
document = $(is).document();
// append in the gexf.
$(document).find("#graphlib-source").append(result);
writeDocument(document, os);
} catch (SAXException e) {
throw new IOException("Exception loading document.", e);
}
}
代码示例来源:origin: org.jboss.windup/windup-grapher
public void writeGraph(final OutputStream os) throws IOException {
// read in the html template resource.
InputStream is = this.getClass().getClassLoader().getResourceAsStream("dagred3/HtmlTemplate.html");
String result;
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
writer.writeGraph(baos);
result = baos.toString();
}
if(LOG.isDebugEnabled()) {
LOG.debug("Graphlib: "+result);
}
// read the document.
Document document;
try {
document = $(is).document();
// append in the gexf.
$(document).find("#graphlib-source").append(result);
writeDocument(document, os);
} catch (SAXException e) {
throw new IOException("Exception loading document.", e);
}
}
代码示例来源:origin: org.jboss.windup/windup-grapher
public void writeGraph(final OutputStream os) throws IOException {
// read in the html template resource.
InputStream is = this.getClass().getClassLoader().getResourceAsStream("sigmajs/HtmlTemplate.html");
String result = null;
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
gexfWriter.writeGraph(baos);
result = baos.toString();
}
if(LOG.isDebugEnabled()) {
LOG.debug("GEXF: "+result);
}
// read the document.
Document document;
try {
document = $(is).document();
// append in the gexf.
$(document).find("#gexf-source").append(result);
writeDocument(document, os);
} catch (SAXException e) {
throw new IOException("Exception loading document.", e);
}
}
代码示例来源:origin: windup/windup
try
document = $(is).document();
代码示例来源:origin: org.jboss.windup.reporting/windup-reporting-impl
private void writeGraph(final OutputStream os) throws IOException
{
// read in the html template resource.
try (InputStream is = this.getClass().getClassLoader().getResourceAsStream("dagred3/HtmlTemplate.html"))
{
String result;
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
writer.writeGraph(baos);
result = baos.toString();
}
if (LOG.isLoggable(Level.FINE))
{
LOG.fine("Graphlib: " + result);
}
// read the document.
Document document;
try
{
document = $(is).document();
// append in the gexf.
$(document).find("#graphlib-source").append(result);
writeDocument(document, os);
}
catch (SAXException e)
{
throw new IOException("Exception loading document.", e);
}
}
}
代码示例来源:origin: windup/windup
private void writeGraph(final OutputStream os) throws IOException
{
// read in the html template resource.
try (InputStream is = this.getClass().getClassLoader().getResourceAsStream("dagred3/HtmlTemplate.html"))
{
String result;
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
writer.writeGraph(baos);
result = baos.toString();
}
if (LOG.isLoggable(Level.FINE))
{
LOG.fine("Graphlib: " + result);
}
// read the document.
Document document;
try
{
document = $(is).document();
// append in the gexf.
$(document).find("#graphlib-source").append(result);
writeDocument(document, os);
}
catch (SAXException e)
{
throw new IOException("Exception loading document.", e);
}
}
}
代码示例来源:origin: io.teecube.t3/t3-site-enhancer
private void fixFooter(File htmlFile) throws Exception {
Match document = JOOX.$(htmlFile);
// add non endorsement warning
document.xpath("//p[@class='copyright']").prepend(this.getPropertyValue("nonEndorsement") + "<br />");
Match version = JOOX.$(JOOX.$(document.xpath("//p[@class='version-date']").get(0)));
// add time to the date if we are in SNAPSHOT version
Element projectVersion = version.xpath("//span[@class='projectVersion']").get(0);
if (projectVersion != null && projectVersion.getTextContent().contains("SNAPSHOT")) {
Element publishDate = version.xpath("//span[@class='publishDate']").get(0);
if (publishDate != null) {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
publishDate.setTextContent(publishDate.getTextContent().substring(0, publishDate.getTextContent().length()-2) + " " + sdf.format(cal.getTime()));
}
}
printDocument(document.document(), htmlFile);
}
代码示例来源:origin: io.teecube.t3/t3-site-enhancer
private void addSocial(File htmlFile) throws Exception {
String socialLinks = this.getPropertyValue("socialLinks");
if (socialLinks == null || socialLinks.isEmpty()) {
return;
}
Match document = JOOX.$(htmlFile);
// add non endorsement warning
document.xpath("//ul[@class='nav pull-right']").prepend(socialLinks);
printDocument(document.document(), htmlFile);
}
代码示例来源:origin: io.teecube.t3/t3-site-enhancer
@Override
public void processHTMLFile(File htmlFile) throws Exception {
if ("maven-archetype".equals(project.getPackaging()) || "pom".equals(project.getPackaging())) {
addHTMLEntities(htmlFile);
Match document = JOOX.$(htmlFile);
try {
document.xpath("//div[@class='main-body']/div[@class='row']/div[@class='span8']").attr("class", "span12");
} catch (Exception e) {
removeHTMLEntities(htmlFile);
return;
}
getLog().debug(project.getPackaging());
getLog().debug(htmlFile.getAbsolutePath());
printDocument(document.document(), htmlFile);
if ("maven-archetype".equals(project.getPackaging())) {
HtmlCanvas html = getArchetypeSection();
replaceByLine(htmlFile,
"<div class=\"body-content\">.*</p></div>",
"<div class=\"body-content\">" + html.toHtml() + "</div>");
}
removeHTMLEntities(htmlFile);
}
}
代码示例来源:origin: io.teecube.t3/t3-site-enhancer
printDocument(document.document(), htmlFile);
代码示例来源:origin: io.teecube.t3/t3-site-enhancer
printDocument(document.document(), htmlFile);
代码示例来源:origin: io.teecube.t3/t3-site-enhancer
private void removeIgnoredParameters(File htmlFile) throws Exception {
Match document = JOOX.$(htmlFile);
// remove ignored parameters
Match td = document.xpath("//tr[./td/b/a/@href='#ignoredParameters']");
td.remove();
Match hre = document.xpath("//p[./b/a/@name='ignoredParameters']/following-sibling::hr[1]");
hre.remove();
Match ul = document.xpath("//p[./b/a/@name='ignoredParameters']/following-sibling::ul[1]");
ul.remove();
Match div = document.xpath("//p[./b/a/@name='ignoredParameters']/following-sibling::div[1]");
div.remove();
Match p = document.xpath("//p[./b/a/@name='ignoredParameters']");
p.remove();
printDocument(document.document(), htmlFile);
}
代码示例来源:origin: io.teecube.t3/t3-site-enhancer
@Override
public void processHTMLFile(File htmlFile) throws Exception {
addHTMLEntities(htmlFile);
Match document;
Match reportsMenu;
Match infosMenu;
try {
document = JOOX.$(htmlFile);
reportsMenu = document.xpath("//div[@id='top-nav-collapse']/ul/li/ul/li[a/@title='Project Reports']");
infosMenu = document.xpath("//div[@id='top-nav-collapse']/ul/li/ul/li[a/@title='Project Information']");
} catch (Exception e) {
removeHTMLEntities(htmlFile);
return;
}
replaceByLine(htmlFile, "<li class=\"disabled\"><a title=\"#reports\">#reports</a></li>", reportsMenu.content());
replaceByLine(htmlFile, "<li class=\"disabled\"><a title=\"#infos\">#infos</a></li>", infosMenu.content());
document = JOOX.$(htmlFile);
document.xpath("//div[@id='top-nav-collapse']/ul/li[ul/li[a/@title='Project Reports']][2]").remove();
document.xpath("//footer/div/div/div/ul/li[a/@title='#infos']").remove();
document.xpath("//footer/div/div/div/ul/li[a/@title='#reports']").remove();
printDocument(document.document(), htmlFile);
removeHTMLEntities(htmlFile);
}
内容来源于网络,如有侵权,请联系作者删除!