org.w3c.dom.html.HTMLDocument Java Examples
The following examples show how to use
org.w3c.dom.html.HTMLDocument.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OutputFormat.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #2
Source File: DomBasedScriptingEngineFactory.java From lams with GNU General Public License v2.0 | 6 votes |
/** * 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(); } }
Example #3
Source File: OutputFormat.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #4
Source File: OutputFormat.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #5
Source File: OutputFormat.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * 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; }
Example #6
Source File: OutputFormat.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * 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; }
Example #7
Source File: OutputFormat.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #8
Source File: OutputFormat.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #9
Source File: OutputFormat.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #10
Source File: ShowPanelFrame.java From oim-fx with MIT License | 6 votes |
private void initEvent() { button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Document doc = webPage.getDocument(webPage.getMainFrame()); if (doc instanceof HTMLDocument) { HTMLDocument htmlDocument = (HTMLDocument) doc; Element e = htmlDocument.createElement("div"); e.setTextContent("hhhhhhh"); HTMLElement htmlDocumentElement = (HTMLElement)htmlDocument.getDocumentElement(); HTMLElement htmlBodyElement = (HTMLElement)htmlDocumentElement.getElementsByTagName("body").item(0); //e.setAttribute(name, value); //org.w3c.dom.Node n=htmlBodyElement.getLastChild();; htmlBodyElement.appendChild(e); webPage.getClientInsertPositionOffset(); // htmlBodyElement.ge //hd.appendChild(e); System.out.println(e.getClass()); } } }); }
Example #11
Source File: OutputFormat.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #12
Source File: OutputFormat.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #13
Source File: OutputFormat.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #14
Source File: OutputFormat.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #15
Source File: OutputFormat.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #16
Source File: OutputFormat.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #17
Source File: OutputFormat.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #18
Source File: OutputFormat.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #19
Source File: OutputFormat.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * 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; }
Example #20
Source File: OutputFormat.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * 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; }
Example #21
Source File: CarteIT.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public static Node parse( String content ) throws SAXException, IOException { DOMFragmentParser parser = new DOMFragmentParser(); HTMLDocument document = new HTMLDocumentImpl(); DocumentFragment fragment = document.createDocumentFragment(); InputSource is = new InputSource( new StringReader( content ) ); parser.parse( is, fragment ); return fragment; }
Example #22
Source File: HtmlContent.java From LoboBrowser with MIT License | 5 votes |
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; }
Example #23
Source File: HtmlContent.java From LoboBrowser with MIT License | 5 votes |
public HtmlContent(final HTMLDocument document, final HtmlPanel panel, final String sourceCode) { super(); this.document = document; this.panel = panel; this.ris = null; this.charset = null; this.sourceCode = sourceCode; }
Example #24
Source File: JTidyHTMLParser.java From lams with GNU General Public License v2.0 | 5 votes |
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" ); } }
Example #25
Source File: NekoHTMLParser.java From lams with GNU General Public License v2.0 | 5 votes |
/** * 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(); } }
Example #26
Source File: ExtensionImpl.java From LoboBrowser with MIT License | 5 votes |
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), "cobra: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); }
Example #27
Source File: HTMLPage.java From lams with GNU General Public License v2.0 | 5 votes |
/** * 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(); } }); }
Example #28
Source File: WritePanel.java From oim-fx with MIT License | 5 votes |
private void updateStyle() { Document doc = webPage.getDocument(webPage.getMainFrame()); if (doc instanceof HTMLDocument) { HTMLDocument htmlDocument = (HTMLDocument) doc; HTMLElement htmlDocumentElement = (HTMLElement) htmlDocument.getDocumentElement(); HTMLElement htmlBodyElement = (HTMLElement) htmlDocumentElement.getElementsByTagName("body").item(0); htmlBodyElement.setAttribute("style", createStyleValue().toString()); } }
Example #29
Source File: WritePanel.java From oim-fx with MIT License | 5 votes |
public void insertImage(String path, String id, String name, String value) { Document doc = webPage.getDocument(webPage.getMainFrame()); if (doc instanceof HTMLDocument) { HTMLDocument htmlDocument = (HTMLDocument) doc; HTMLElement htmlDocumentElement = (HTMLElement) htmlDocument.getDocumentElement(); HTMLElement htmlBodyElement = (HTMLElement) htmlDocumentElement.getElementsByTagName("body").item(0); if (htmlBodyElement instanceof HTMLBodyElementImpl) { // HTMLBodyElementImpl htmlBodyElementImpl = // (HTMLBodyElementImpl) htmlBodyElement; // Element e = htmlBodyElementImpl.getOffsetParent(); // htmlBodyElementImpl.insertBefore(newChild, refChild) // htmlDocument. } Element e = htmlDocument.createElement("img"); e.setAttribute("id", id); e.setAttribute("name", name); e.setAttribute("value", value); e.setAttribute("src", path); // webEngine.get // webView.get int positionOffset = webPage.getClientInsertPositionOffset(); int index = (positionOffset + 1); NodeList nodeList = htmlBodyElement.getChildNodes(); int length = nodeList.getLength(); if (index < 0) { htmlBodyElement.appendChild(e); } else if (index < length) { org.w3c.dom.Node node = nodeList.item(index); htmlBodyElement.insertBefore(e, node); } else { htmlBodyElement.appendChild(e); } webPage.getClientInsertPositionOffset(); } }
Example #30
Source File: ShowPanel.java From oim-fx with MIT License | 5 votes |
public void insertLast(String text, String fontName, int fontSize, String color, boolean bold, boolean underline, boolean italic) { Document doc = webPage.getDocument(webPage.getMainFrame()); if (doc instanceof HTMLDocument) { HTMLDocument htmlDocument = (HTMLDocument) doc; HTMLElement htmlDocumentElement = (HTMLElement) htmlDocument.getDocumentElement(); HTMLElement htmlBodyElement = (HTMLElement) htmlDocumentElement.getElementsByTagName("body").item(0); Element element = htmlDocument.createElement("div"); element.setTextContent(text); element.setAttribute("style", createStyleValue(fontName, fontSize, color, bold, underline, italic).toString()); htmlBodyElement.appendChild(element); } }