當前位置: 首頁>>代碼示例>>Java>>正文


Java Tidy.setMakeClean方法代碼示例

本文整理匯總了Java中org.w3c.tidy.Tidy.setMakeClean方法的典型用法代碼示例。如果您正苦於以下問題:Java Tidy.setMakeClean方法的具體用法?Java Tidy.setMakeClean怎麽用?Java Tidy.setMakeClean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.w3c.tidy.Tidy的用法示例。


在下文中一共展示了Tidy.setMakeClean方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: cleanNfo

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
/**
 * Try to clean the NFO(XML) content with JTidy.
 * 
 * @param sourceNfoContent
 *          the XML content to be cleaned
 * @return the cleaned XML content (or the source, if any Exceptions occur)
 */
public static String cleanNfo(String sourceNfoContent) {
  try {
    Tidy tidy = new Tidy();
    tidy.setInputEncoding("UTF-8");
    tidy.setOutputEncoding("UTF-8");
    tidy.setWraplen(Integer.MAX_VALUE);
    tidy.setXmlOut(true);
    tidy.setSmartIndent(true);
    tidy.setXmlTags(true);
    tidy.setMakeClean(true);
    tidy.setForceOutput(true);
    tidy.setQuiet(true);
    tidy.setShowWarnings(false);
    StringReader in = new StringReader(sourceNfoContent);
    StringWriter out = new StringWriter();
    tidy.parse(in, out);

    return out.toString();
  }
  catch (Exception e) {
  }
  return sourceNfoContent;
}
 
開發者ID:tinyMediaManager,項目名稱:tinyMediaManager,代碼行數:31,代碼來源:ParserUtils.java

示例2: getDocument

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
/**
 * Permet de retourner un objet de type Document construit autour de sText.
 *
 * @param sText
 *            Le texte original.
 * @param errout
 *            Flux o� sera affich� les erreurs de syntaxe html. Si � null,
 *            alors par d�faut,
 * @param showWarnings
 *            Permet de sp�cifier si on veut que les warnings soient
 *            affich�s ou pas dans errout.
 * @return Un objet de type Document.
 * @throws IOException
 *             Lev�e si une erreur se produit.
 */
private static Document getDocument(String sText, PrintWriter errout,
        boolean showWarnings) throws IOException {
    File temp = File.createTempFile("TwikiToHtml", ".tmp");
    temp.deleteOnExit();
    PrintWriter msg = new PrintWriter(new FileWriter(temp));
    msg.print(sText);
    msg.close();
    // new StringReader(sText);
    Tidy tidy = new Tidy();
    tidy.setShowWarnings(showWarnings);
    tidy.setMakeClean(true);
    tidy.setXHTML(true);
    if (errout != null) {
        tidy.setErrout(errout);
    }
    return tidy.parseDOM(new FileInputStream(temp), null);
}
 
開發者ID:dvorka,項目名稱:mindraider,代碼行數:33,代碼來源:TwikiToHtml.java

示例3: cleanupHtml

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
private String cleanupHtml(String story) {
    Tidy tidy = new Tidy();
    tidy.setInputEncoding(ENCODING);
    tidy.setOutputEncoding(ENCODING);
    tidy.setPrintBodyOnly(true);
    tidy.setXmlOut(true);
    tidy.setSmartIndent(false);
    tidy.setBreakBeforeBR(false);
    tidy.setMakeBare(true);
    tidy.setMakeClean(true);
    tidy.setNumEntities(true);
    tidy.setWraplen(0);

    StringWriter writer = new StringWriter();
    StringReader reader = new StringReader(story);
    tidy.parse(reader, writer);
    return writer.toString();
}
 
開發者ID:getconverge,項目名稱:converge-1.x,代碼行數:19,代碼來源:NewsItemPlacementToAtomConverter.java

示例4: getXHTML

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public static String getXHTML(String html){
	
	Tidy tidy = new Tidy();

	tidy.setXHTML(true);
	tidy.setMakeClean(true);
	tidy.setShowWarnings(false);
	tidy.setShowErrors(0);
	tidy.setQuiet(true);
	tidy.setPrintBodyOnly(true);
	tidy.setOutputEncoding("ISO-8859-1");
	
	StringWriter stringWriter = new StringWriter();
	
	tidy.parse(new StringReader(html), stringWriter);
	
	return stringWriter.toString();
}
 
開發者ID:Sundsvallskommun,項目名稱:Open-ePlatform,代碼行數:19,代碼來源:JTidyUtils.java

示例5: cleanXMLData

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public static String cleanXMLData(String data) throws UnsupportedEncodingException {
   // data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+data;

	Tidy tidy = new Tidy();
    tidy.setInputEncoding("UTF-8");
    tidy.setOutputEncoding("UTF-8");
    tidy.setWraplen(Integer.MAX_VALUE);
  //  tidy.setPrintBodyOnly(true);
    tidy.setXmlOut(true);
    tidy.setXmlTags(true);
    tidy.setSmartIndent(true);
    tidy.setMakeClean(true);
    tidy.setForceOutput(true);
    ByteArrayInputStream inputStream = new ByteArrayInputStream(data.getBytes("UTF-8"));
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    tidy.parseDOM(inputStream, outputStream);
    return outputStream.toString("UTF-8");
}
 
開發者ID:karutaproject,項目名稱:karuta-backend,代碼行數:19,代碼來源:DomUtils.java

示例6: makeTidyParser

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
/**
 * Create a Tidy parser with the specified settings.
 *
 * @param quiet - set the Tidy quiet flag?
 * @param showWarnings - show Tidy warnings?
 * @param isXml - treat the content as XML?
 * @param stringWriter - if non-null, use this for Tidy errorOutput
 * @return the Tidy parser
 */
public static Tidy makeTidyParser(boolean quiet, boolean showWarnings, boolean isXml, StringWriter stringWriter) {
    Tidy tidy = new Tidy();
    tidy.setInputEncoding("UTF8");
    tidy.setOutputEncoding("UTF8");
    tidy.setQuiet(quiet);
    tidy.setShowWarnings(showWarnings);
    tidy.setMakeClean(true);
    tidy.setXmlTags(isXml);
    if (stringWriter != null) {
        tidy.setErrout(new PrintWriter(stringWriter));
    }
    return tidy;
}
 
開發者ID:johrstrom,項目名稱:cloud-meter,代碼行數:23,代碼來源:XPathUtil.java

示例7: getXHTML

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
private String getXHTML( String _html ){
	Tidy tidy = new Tidy();
	tidy.setQuiet( true );
	tidy.setNumEntities( true );
	tidy.setShowWarnings( false );
	StringWriter result = new StringWriter();
	tidy.setMakeClean( true );
	tidy.setXHTML( true );
	tidy.parse( new StringReader( _html ), result );

	return result.toString();
}
 
開發者ID:OpenBD,項目名稱:openbd-core,代碼行數:13,代碼來源:cfDOCUMENT.java

示例8: tidyDocument

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
protected ByteArrayInputStream tidyDocument(InputStream inputStream) throws FileNotFoundException, IOException {
	
	Tidy tidy = new Tidy();
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	tidy.setTrimEmptyElements(true);
	tidy.setMakeClean(true);
	tidy.setQuoteNbsp(true);
	tidy.setXmlOut(true);
	tidy.setInputEncoding("UTF-8");
	tidy.parseDOM(inputStream, outputStream);
	
	LOGGER.trace(outputStream.toString("UTF-8"));
	
	return new ByteArrayInputStream(outputStream.toByteArray());
}
 
開發者ID:premiummarkets,項目名稱:pm,代碼行數:16,代碼來源:GnuCashParserHelper.java

示例9: execute

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public cfData execute(cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException {
	try{
		Tidy tidy	= new Tidy();

		final StringBuilder	errors	= new StringBuilder(32);
		
		tidy.setMessageListener( new TidyMessageListener(){
		public void messageReceived(TidyMessage mess) {
			errors.append( "Line: " + mess.getLine() + "." + mess.getColumn() + "; " + mess.getMessage() + "\r\n" );
		}
		});

  	tidy.setSmartIndent( false );
  	tidy.setSpaces( 2 );
  	tidy.setTabsize( 2 );
  	tidy.setWraplen( 0 );

  	tidy.setLogicalEmphasis( true );
  	tidy.setMakeClean( true );
  	tidy.setQuiet( true );
  	tidy.setDropEmptyParas( true );
  	tidy.setXHTML( true );
  	tidy.setXmlSpace( true );
  	tidy.setTrimEmptyElements( true );
  	tidy.setBreakBeforeBR( false );
  	tidy.setUpperCaseTags( false );
  	tidy.setUpperCaseAttrs( false );
  	tidy.setWord2000( true );

  	tidy.setFixUri(false);
  	tidy.setFixBackslash( false );
  	tidy.setIndentAttributes( false );
  	tidy.setShowWarnings( false );
  	tidy.setShowErrors( 1 );
  	tidy.setOnlyErrors( false );

  	tidy.setPrintBodyOnly( false );
  	tidy.setJoinClasses( true );
  	tidy.setJoinStyles( true );
  	
  	String inHtml = getNamedStringParam(argStruct,"string","");
  	
  	StringReader reader = new StringReader( inHtml );
  	StringWriter writer = new StringWriter();
  	tidy.parse( reader, writer );
  	
  	if ( errors.length() != 0 ){
  		throwException( _session, errors.toString() );
  		return null;
  	}else{
  	
   	String outHtml	= writer.toString();
   	int c1	= outHtml.indexOf("<body>");
   	if ( c1 >= 0 ){
   		outHtml	= outHtml.substring( c1 + 6 );
   		c1 = outHtml.lastIndexOf("</body>");
   		if ( c1 >= 0 ){
   			outHtml	= outHtml.substring( 0, c1 );
   		}
   	}

   	return new cfStringData( outHtml );
  	}
  	
	}catch( Exception e ){
		throwException( _session, e.getMessage() );
		return null;
	}
}
 
開發者ID:OpenBD,項目名稱:openbd-core,代碼行數:70,代碼來源:HtmlCleanUp.java

示例10: tidyHTML

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
private static String tidyHTML(String content)
								throws IOException{
	Tidy tidy = new Tidy();
	
	// set configuration values
	tidy.setDropEmptyParas(false); // drop empty P elements
	tidy.setDocType("omit"); // omit the doctype
	tidy.setEncloseBlockText(true); // wrap blocks of text in P elements
	tidy.setEncloseText(true); // wrap text right under BODY element in P elements
	tidy.setHideEndTags(false); // force optional end tags
	tidy.setIndentContent(false); // indent content for easy reading
	tidy.setLiteralAttribs(false); // no new lines in attributes
	tidy.setLogicalEmphasis(false); // replace i and b by em and strong, respectively
	tidy.setMakeClean(false); // strip presentational cruft
	tidy.setNumEntities(true); // convert entities to their numeric form
	tidy.setWord2000(true); // strip Word 2000 cruft
	tidy.setXHTML(true); // output XHTML
	tidy.setXmlPi(true); // add <?xml?> processing instruction
	
	// parse
	StringReader in = new StringReader(content);
	StringWriter out = new StringWriter();
	tidy.parse(in, out);
	in.close();
	out.close();
	String results = out.toString();
	
	// remove the XML namespace declaration,
	// since it makes trouble for us in the XPath
	// evaluator
	// FIXME: this is ghetto and needs to be fixed
	// with a namespace evaluator in the XPath section,
	// but namespace evaluators are a pain in the butt
	// to get working
	
	// String.replace() does not work on 1.4 JVMs when compiled
	// with 1.5 JVMs, even with target="1.4" (this is a known Java
	// bug). Using workaround instead. -- Brad Neuberg
	//results = results.replace("xmlns=\"http://www.w3.org/1999/xhtml\"", "");
	
	StringBuffer buffer = new StringBuffer(results);
	int startCut = buffer.indexOf("xmlns=\"http://www.w3.org/1999/xhtml\"");
	if(startCut != -1){
		buffer.replace(startCut, 
						startCut + "xmlns=\"http://www.w3.org/1999/xhtml\"".length(), 
						"");
		results = buffer.toString();
	}
	
	//System.out.println("tidied results="+results);
			
	return results;
}
 
開發者ID:BradNeuberg,項目名稱:purple-include,代碼行數:54,代碼來源:Resolver.java

示例11: convertToXMLOLD

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public static String convertToXMLOLD(String xml){
	//======================================
//	String newXML = xml;
//	String xml1 = "";
//	String xml2 = "";
//	String html = "";
//	if (xml.indexOf("<text>")>-1) {
//	xml1 = xml.substring(0,xml.indexOf("<text>")+6);
//	xml2 = xml.substring(xml.indexOf("</text>"));
//	html = xml.substring(xml.indexOf("<text>")+6,xml.indexOf("</text>"));
//	}
//	if (xml.indexOf("<comment>")>-1) {
//	xml1 = xml.substring(0,xml.indexOf("<comment>")+9);
//	xml2 = xml.substring(xml.indexOf("</comment>"));
//	html = xml.substring(xml.indexOf("<comment>")+9,xml.indexOf("</comment>"));
//	}
//	if (xml.indexOf("<description>")>-1) {
//	xml1 = xml.substring(0,xml.indexOf("<description>")+13);
//	xml2 = xml.substring(xml.indexOf("</description>"));
//	html = xml.substring(xml.indexOf("<description>")+13,xml.indexOf("</description>"));
//	}
//	if (html.length()>0) {  // xml is html
//	html = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'><head><title></title></head><body>" +html+"</body>";
	StringReader in = new StringReader(xml);
	StringWriter out = new StringWriter();
	Tidy tidy = new Tidy();
	tidy.setInputEncoding("UTF-8");
    tidy.setOutputEncoding("UTF-8");
    tidy.setWraplen(Integer.MAX_VALUE);
    tidy.setPrintBodyOnly(true);
	tidy.setMakeClean(true);
//	tidy.setForceOutput(true);
    tidy.setSmartIndent(true);
    tidy.setXmlTags(true);
	tidy.setXmlOut(true);

//	tidy.setWraplen(0);
	tidy.parseDOM(in, out);
	String newXML = out.toString();
//	newXML = xml1+newHTML.substring(newHTML.indexOf("<body>")+6,newHTML.indexOf("</body>"))+xml2;
//	} else {
//	newXML =xml;
//	}
//	return newXML;
	return newXML;
	}
 
開發者ID:karutaproject,項目名稱:karuta-backend,代碼行數:47,代碼來源:DomUtils.java

示例12: scrapeOutletStatuses

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
/**
 * Scrapes the name, number and status of outlets. 
 * 
 * @param in input stream of plugs page
 * @param out output stream to print tidy debug out
 * @return whether scraping was successful (assumes there will be a \ 
 *      mutliple of 8 plugs
 * @throws Exception error reading or writing to streams
 */
private boolean scrapeOutletStatuses(InputStream in, OutputStream out) throws Exception
{
    List<Outlet> outs = new ArrayList<Outlet>();
    
    Tidy tidy = new Tidy();
    tidy.setAsciiChars(true);
    tidy.setHideComments(true);
    tidy.setMakeBare(true);
    tidy.setMakeClean(true);
    tidy.setDropFontTags(true);
    tidy.setXmlOut(true);
    tidy.setErrout(NullWriter.getPrintWriter());

    Document doc = tidy.parseDOM(in, out);
    NodeList trList = doc.getElementsByTagName("tr");
    for (int i = 0; i < trList.getLength(); i++)
    {
        NodeList tdList = trList.item(i).getChildNodes();

        /* The table with the identifier outlet information contains 7 columns. */
        if (tdList.getLength() != 7) continue;
        
        /* The first row with headings has 'Plug' in the first column. */
        Node node = tdList.item(0);
        if ("Plug".equals(this.getCellContent(node))) continue;
       
        /* If the two preceding conditions are satisfied, we should have a row. */
        Outlet outlet = new Outlet();
        
        /* First column has plug number. */
        try
        {
            outlet.number = Integer.parseInt(this.getCellContent(node));
        }
        catch (NumberFormatException ex) { continue; }

        /* Second column has plug name. */
        outlet.name = this.getCellContent(tdList.item(1));
        
        /* Third column has the plug state  using an image. The alt 
         * attribute has a textual representation of the state,
         * either 'On' or 'Off'. */
        Node img = tdList.item(2).getFirstChild();
        if (!"img".equals(img.getNodeName())) continue;
        outlet.isOn = "ON".equalsIgnoreCase(img.getAttributes().getNamedItem("alt").getNodeValue());
        
        this.logger.debug("Scraped: " + outlet);
        outs.add(outlet);
    }
    
    this.outlets = outs;
    return this.outlets.size() > 0 && this.outlets.size() % 8 == 0;
}
 
開發者ID:sahara-labs,項目名稱:rig-client-commons,代碼行數:63,代碼來源:InternetPowerSwitchControl.java


注:本文中的org.w3c.tidy.Tidy.setMakeClean方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。