当前位置: 首页>>代码示例>>Java>>正文


Java HTMLDocument类代码示例

本文整理汇总了Java中org.w3c.dom.html.HTMLDocument的典型用法代码示例。如果您正苦于以下问题:Java HTMLDocument类的具体用法?Java HTMLDocument怎么用?Java HTMLDocument使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HTMLDocument类属于org.w3c.dom.html包,在下文中一共展示了HTMLDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: load

import org.w3c.dom.html.HTMLDocument; //导入依赖的package包/类
/**
 * load
 * @param response
 */
public void load( WebResponse response ) {
		Function onLoadEvent=null;
    try {
        Context context = Context.enter();
        context.initStandardObjects( null );

        HTMLDocument htmlDocument = ((DomWindow) response.getScriptingHandler()).getDocument();
        if (!(htmlDocument instanceof HTMLDocumentImpl)) return;

        HTMLBodyElementImpl body = (HTMLBodyElementImpl) htmlDocument.getBody();
        if (body == null) return;
        onLoadEvent = body.getOnloadEvent();
        if (onLoadEvent == null) return;
        onLoadEvent.call( context, body, body, new Object[0] );
    } catch (JavaScriptException e) {
    	ScriptingEngineImpl.handleScriptException(e, onLoadEvent.toString());
    	// HttpUnitUtils.handleException(e);
    } catch (EcmaError ee) {
    	//throw ee;
    	ScriptingEngineImpl.handleScriptException(ee, onLoadEvent.toString());        	
    } finally {
        Context.exit();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:DomBasedScriptingEngineFactory.java

示例2: whichDoctypePublic

import org.w3c.dom.html.HTMLDocument; //导入依赖的package包/类
/**
 * Returns the document type public identifier
 * specified for this document, or null.
 */
public static String whichDoctypePublic( Document doc )
{
    DocumentType doctype;

       /*  DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getPublicId();
       } catch ( Error except ) {  }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLPublicId;
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:OutputFormat.java

示例3: whichDoctypeSystem

import org.w3c.dom.html.HTMLDocument; //导入依赖的package包/类
/**
 * Returns the document type system identifier
 * specified for this document, or null.
 */
public static String whichDoctypeSystem( Document doc )
{
    DocumentType doctype;

    /* DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getSystemId();
       } catch ( Error except ) { }
       }

    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLSystemId;
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:OutputFormat.java

示例4: JProxyExampleDocument

import org.w3c.dom.html.HTMLDocument; //导入依赖的package包/类
public JProxyExampleDocument(ItsNatServletRequest request,ItsNatHTMLDocument itsNatDoc,FalseDB db)
{       
    this.itsNatDoc = itsNatDoc;

    HTMLDocument doc = itsNatDoc.getHTMLDocument();

    ItsNatComponentManager compMgr = itsNatDoc.getItsNatComponentManager();
    this.textInput = (ItsNatHTMLInputText)compMgr.createItsNatComponentById("inputId");


    EventListener listener = new EventListener()
    {        
        @Override
        public void handleEvent(Event evt) 
        {           	
            String text = textInput.getText();
            String comment = "  YES I SAID THAT"; // " YES I SAID THAT";                
            resultsElem.setTextContent(text + comment);
        }
    };
    
    Element buttonElem = doc.getElementById("buttonId");
    ((EventTarget)buttonElem).addEventListener("click",listener,false);

    this.resultsElem = doc.getElementById("resultsId");            
}
 
开发者ID:jmarranz,项目名称:relproxy_examples,代码行数:27,代码来源:JProxyExampleDocument.java

示例5: parseHTML

import org.w3c.dom.html.HTMLDocument; //导入依赖的package包/类
/**
 * 从指定流解析HTML
 * 
 * @param in
 *            输入流
 * @param charSet
 *            字符集,为null时自动检测
 * @return 解析后的DocumentFragment对象
 * @throws SAXException
 *             XML语法异常时抛出
 * @throws IOException
 *             IO操作错误时抛出
 */
public static DocumentFragment parseHTML(InputStream in, String charSet) throws SAXException, IOException {
	if (parser == null)
		throw new UnsupportedOperationException(
				"HTML parser module not loaded, to activate this feature, you must add JEF common-ioc.jar to classpath");
	InputSource source;
	if (charSet != null) {
		source = new InputSource(new XmlFixedReader(new InputStreamReader(in, charSet)));
		source.setEncoding(charSet);
	} else {
		source = new InputSource(in);
	}
	synchronized (parser) {
		HTMLDocument document = new HTMLDocumentImpl();
		DocumentFragment fragment = document.createDocumentFragment();
		parser.parse(source, fragment);
		return fragment;
	}
}
 
开发者ID:GeeQuery,项目名称:ef-orm,代码行数:32,代码来源:XMLUtils.java

示例6: createDocument

import org.w3c.dom.html.HTMLDocument; //导入依赖的package包/类
/** Works around weird linkage problem, SPF-8671,
	 * in some builds, where one plugin can import this
	 * and another can't.
	 * @param title 
	 * @return
	 */
	public static HTMLDocument createDocument(String title) {
//		ClassLoader.getSystemClassLoader().loadClass("org.apache.html.dom.HTMLDOMImplementationImpl", true);
		LogUtil.warn("Static " + PlanDiffOutputAsTreeHTML.DOM + " is class " + PlanDiffOutputAsTreeHTML.DOM.getClass());
		LogUtil.warn(DOM + " is class " + DOM.getClass());

		// FIXME:  It's a complete mystery ?why the simple call below doesn't work.  See SPF-8671.
		return DOM.createHTMLDocument(title);
//		try {
//			Class<?> class1 = ClassLoader.getSystemClassLoader().loadClass("org.apache.html.dom.HTMLDOMImplementationImpl");
//			Class <? extends HTMLDOMImplementation> class2 = (Class<? extends HTMLDOMImplementation>) class1;
//			return class2.getMethod(", arg1)
//		} catch (Exception e) {
//			LogUtil.error(e);
//			return null;
//		}
	}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:23,代码来源:HTMLReportUtil.java

示例7: serializeToString

import org.w3c.dom.html.HTMLDocument; //导入依赖的package包/类
/**
 * The subtree rooted by the specified element is serialized to a string.
 * 
 * @param root
 *            the root of the subtree to be serialized (this may be any
 *            node, even a document)
 * @return the serialized string
 */
public String serializeToString(Node root) {
	TransformerFactory tf = TransformerFactory.newInstance();
	Transformer transformer;
	try {
		if (root instanceof Document) {
			return documentToString((Document) root);
		} else if (root instanceof DocumentFragment) {
			if (root.getOwnerDocument() instanceof HTMLDocument) {
				return "";
			}
			root = root.getFirstChild();
		}

		transformer = tf.newTransformer();
		transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
		StringWriter writer = new StringWriter();
		transformer.transform(new DOMSource(root), new StreamResult(writer));
		return writer.getBuffer().toString().replaceAll("\n|\r", "");
	} catch (TransformerException e) {
		logger.error(e.getMessage());
	}
	return "";
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:32,代码来源:XMLSerializer.java

示例8: whichDoctypePublic

import org.w3c.dom.html.HTMLDocument; //导入依赖的package包/类
/**
 * Returns the document type public identifier
 * specified for this document, or null.
 */
public static String whichDoctypePublic( Document doc )
{
    DocumentType doctype;

       /*  DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getPublicId();
       } catch ( Error except ) {  }
       }
    
    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLPublicId;
    return null;
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:23,代码来源:OutputFormat.java

示例9: whichDoctypeSystem

import org.w3c.dom.html.HTMLDocument; //导入依赖的package包/类
/**
 * Returns the document type system identifier
 * specified for this document, or null.
 */
public static String whichDoctypeSystem( Document doc )
{
    DocumentType doctype;

    /* DOM Level 2 was introduced into the code base*/
       doctype = doc.getDoctype();
       if ( doctype != null ) {
       // Note on catch: DOM Level 1 does not specify this method
       // and the code will throw a NoSuchMethodError
       try {
       return doctype.getSystemId();
       } catch ( Error except ) { }
       }
    
    if ( doc instanceof HTMLDocument )
        return DTD.XHTMLSystemId;
    return null;
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:23,代码来源:OutputFormat.java

示例10: JProxyExampleDocument

import org.w3c.dom.html.HTMLDocument; //导入依赖的package包/类
public JProxyExampleDocument(ItsNatServletRequest request,ItsNatHTMLDocument itsNatDoc,FalseDB db)
{       
    this.itsNatDoc = itsNatDoc;

    HTMLDocument doc = itsNatDoc.getHTMLDocument();

    ItsNatComponentManager compMgr = itsNatDoc.getItsNatComponentManager();
    this.textInput = (ItsNatHTMLInputText)compMgr.createItsNatComponentById("inputId");


    EventListener listener = new EventListener()
    {        
        @Override
        public void handleEvent(Event evt) 
        {
            String text = textInput.getText();
            String comment = "  YES I SAID THAT"; // " YES I SAID THAT";                
            resultsElem.setTextContent(text + comment);
        }
    };
    
    Element buttonElem = doc.getElementById("buttonId");
    ((EventTarget)buttonElem).addEventListener("click",listener,false);

    
    this.resultsElem = doc.getElementById("resultsId");            
}
 
开发者ID:jmarranz,项目名称:relproxy_examples,代码行数:28,代码来源:JProxyExampleDocument.java

示例11: parse

import org.w3c.dom.html.HTMLDocument; //导入依赖的package包/类
/**
 * parse the given test with the given URL
 * @param text
 * @param pageURL
 * @throws SAXException
 * @throws IOException
 */
public void parse( String text, URL pageURL ) throws SAXException, IOException {
    HTMLParserFactory.getHTMLParser().parse( pageURL, text, new DocumentAdapter() {
        public void setDocument(HTMLDocument document ) { HTMLPage.this.setRootNode( document ); }
        public String getIncludedScript( String srcAttribute ) throws IOException { return HTMLPage.this.getIncludedScript( srcAttribute ); }
        public ScriptingHandler getScriptingHandler() { return getResponse().getScriptingHandler(); }
    });
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:HTMLPage.java

示例12: parse

import org.w3c.dom.html.HTMLDocument; //导入依赖的package包/类
/**
* parse the given URL with the given pageText using the given document adapter
* @param pageURL
* @param pageText
* @param adapter
*/
public void parse( URL pageURL, String pageText, DocumentAdapter adapter ) throws IOException, SAXException {
    try {
        NekoDOMParser parser = NekoDOMParser.newParser( adapter, pageURL );
        parser.parse( new InputSource( new StringReader( pageText ) ) );
        Document doc=parser.getDocument();
       	adapter.setDocument( (HTMLDocument)doc );
    } catch (NekoDOMParser.ScriptException e) {
         throw e.getException();
    }     
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:NekoHTMLParser.java

示例13: parse

import org.w3c.dom.html.HTMLDocument; //导入依赖的package包/类
public void parse( URL pageURL, String pageText, DocumentAdapter adapter ) throws IOException, SAXException {
    try {
        Document jtidyDocument = getParser( pageURL ).parseDOM( new ByteArrayInputStream( pageText.getBytes( UTF_ENCODING ) ), null );
        HTMLDocument htmlDocument = new HTMLDocumentImpl();
        NodeList nl = jtidyDocument.getChildNodes();
        for (int i = 0; i < nl.getLength(); i++) {
            Node importedNode = nl.item(i);
            if (importedNode.getNodeType() != Node.DOCUMENT_TYPE_NODE) htmlDocument.appendChild( htmlDocument.importNode( importedNode, true ) );
        }
        adapter.setDocument( htmlDocument );
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException( "UTF-8 encoding failed" );
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:JTidyHTMLParser.java

示例14: HtmlContent

import org.w3c.dom.html.HTMLDocument; //导入依赖的package包/类
public HtmlContent(final HTMLDocument document, final HtmlPanel panel, final RecordedInputStream ris, final String charset) {
  super();
  this.document = document;
  this.panel = panel;
  this.ris = ris;
  this.charset = charset;
  this.sourceCode = null;
}
 
开发者ID:lobobrowser,项目名称:LoboBrowser,代码行数:9,代码来源:HtmlContent.java

示例15: getErrorComponent

import org.w3c.dom.html.HTMLDocument; //导入依赖的package包/类
private static ComponentContent getErrorComponent(final NavigatorFrame frame, final ClientletResponse response, final Throwable exception) {
  final HtmlPanel panel = new HtmlPanel();
  final HtmlRendererContext rcontext = HtmlRendererContextImpl.getHtmlRendererContext(frame);
  panel.setHtml(getErrorHtml(response, exception), "about:error", rcontext);
  String sourceCode = "[NOT AVAILABLE]";
  if (exception instanceof ClientletException) {
    final ClientletException ce = (ClientletException) exception;
    final String sc = ce.getSourceCode();
    if (sc != null) {
      sourceCode = sc;
    }
  }
  return new HtmlContent((HTMLDocument) panel.getRootNode(), panel, sourceCode);
}
 
开发者ID:lobobrowser,项目名称:LoboBrowser,代码行数:15,代码来源:ExtensionImpl.java


注:本文中的org.w3c.dom.html.HTMLDocument类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。