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


Java Tidy.setXmlPi方法代碼示例

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


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

示例1: ConverterXhtml

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
public void ConverterXhtml(String fileHtml, String fileXhtmlAux) throws Exception {

        Tidy tidy = new Tidy();

        FileInputStream in = new FileInputStream(fileHtml);
        FileOutputStream out = new FileOutputStream(fileXhtmlAux);

        tidy.setTidyMark(false);
        tidy.setDocType("omit");
        tidy.setAltText("");
        tidy.setFixBackslash(true);
        tidy.setFixComments(true);
        tidy.setXmlPi(true);
        tidy.setQuoteAmpersand(true);
        tidy.setQuoteNbsp(true);
        tidy.setNumEntities(true);
        tidy.setXmlOut(true);
        tidy.setWraplen(999);
        tidy.setWriteback(true);
        tidy.setQuoteMarks(true);
        tidy.setLogicalEmphasis(true);
        tidy.setEncloseText(true);
        tidy.setHideEndTags(true);
        tidy.setShowWarnings(false);
        tidy.setQuiet(true);
        tidy.setXHTML(true);
        tidy.parse(in, out);

        in.close();
        out.close();


    }
 
開發者ID:triguero,項目名稱:Keel3.0,代碼行數:34,代碼來源:HtmlToKeel.java

示例2: ConverterXhtml

import org.w3c.tidy.Tidy; //導入方法依賴的package包/類
/**
 * Method used to transform the data from the html file given as parameter to 
 * xhtml format file which will be stored in the second file given.
 * @param fileHtml input html file path.
 * @param fileXhtmlAux output xhtml file path.
 * @throws Exception if the files can not be read or written.
 */
public void ConverterXhtml(String fileHtml, String fileXhtmlAux) throws Exception {

    Tidy tidy = new Tidy();

    FileInputStream in = new FileInputStream(fileHtml);
    FileOutputStream out = new FileOutputStream(fileXhtmlAux);

    tidy.setTidyMark(false);
    tidy.setDocType("omit");
    tidy.setAltText("");
    tidy.setFixBackslash(true);
    tidy.setFixComments(true);
    tidy.setXmlPi(true);
    tidy.setQuoteAmpersand(true);
    tidy.setQuoteNbsp(true);
    tidy.setNumEntities(true);
    tidy.setXmlOut(true);
    tidy.setWraplen(999);
    tidy.setWriteback(true);
    tidy.setQuoteMarks(true);
    tidy.setLogicalEmphasis(true);
    tidy.setEncloseText(true);
    tidy.setHideEndTags(true);
    tidy.setShowWarnings(false);
    tidy.setQuiet(true);
    tidy.setXHTML(true);
    tidy.parse(in, out);

    in.close();
    out.close();


}
 
開發者ID:SCI2SUGR,項目名稱:KEEL,代碼行數:41,代碼來源:HtmlToKeel.java

示例3: 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


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