how to access an external style sheet via the Document interface in Java?


I have an interface reference (instanceof Document) pointing to a valid object. The problem is that I want to view the style attribute associated with a particular element in DOM, but it will only expose inline attributes (while style has been set through an external stylesheet). The end goal is to acquire a reference to ViewCSS, as I want to view the associated computed style - how would I do this? I'm presuming, that acquiring a DocumentView object might be needed (if so, how, as I did not find any method that will return the aforementioned object)?

Document document = ...;

document.getImplementation().hasFeature("Views", "2.0"));

this returns true.

Object obj = document.getImplementation().getFeature("Views", "2.0");

this throws an java.lang.UnsupportedOperationException: Not supported yet.

What am I doing wrong, how to fix it and what is the best way to go about this (I want to view/change the associated computed style for this document)? Thank you.


I think this is an important part of details that should have been provided initially:

java.lang.UnsupportedOperationException: Not supported yet.
    at com.sun.webpane.webkit.dom.NodeImpl.getFeature(Unknown Source)

the Document object returned was from a javafx package triggered on WebEngine.

May be this fragment solves your problem:

Document doc = ???;
HTMLDocument htmlDoc = (HTMLDocument)doc;
final HTMLBodyElement body = (HTMLBodyElement)htmlDoc.getBody();

//JS [window] access
DOMWindowImpl wnd =

//Style access
CSSStyleDeclaration style = wnd.getComputedStyle(body, "");
assertEquals("Style extraction", "blue", style.getPropertyValue("background-color"));