public void setSelectorText(final String selectorText) throws DOMException { final CSSStyleSheetImpl parentStyleSheet = getParentStyleSheetImpl(); if (parentStyleSheet != null && parentStyleSheet.isReadOnly()) { throw new DOMExceptionImpl( DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMExceptionImpl.READ_ONLY_STYLE_SHEET); } try { final InputSource is = new InputSource(new StringReader(selectorText)); final CSSOMParser parser = new CSSOMParser(); selectors_ = parser.parseSelectors(is); } catch (final CSSException e) { throw new DOMExceptionImpl( DOMException.SYNTAX_ERR, DOMExceptionImpl.SYNTAX_ERROR, e.getMessage()); } catch (final IOException e) { throw new DOMExceptionImpl( DOMException.SYNTAX_ERR, DOMExceptionImpl.SYNTAX_ERROR, e.getMessage()); } }
/** * Parses the selectors at the specified input source. If anything at all goes wrong, this * method returns an empty selector list. * * @param source the source from which to retrieve the selectors to be parsed * @return the selectors parsed from the specified input source */ SelectorList parseSelectors(final InputSource source) { SelectorList selectors; try { final ErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler(); final CSSOMParser parser = new CSSOMParser(new SACParserCSS21()); parser.setErrorHandler(errorHandler); selectors = parser.parseSelectors(source); } catch (final Exception e) { LOG.error("Error parsing CSS selectors from '" + toString(source) + "': " + e.getMessage(), e); selectors = new SelectorListImpl(); } catch (final Error e) { // SACParser sometimes throws Error: "Missing return statement in function" LOG.error("Error parsing CSS selectors from '" + toString(source) + "': " + e.getMessage(), e); selectors = new SelectorListImpl(); } return selectors; }
/** * Parses the selectors at the specified input source. If anything at all goes wrong, this * method returns an empty selector list. * * @param source the source from which to retrieve the selectors to be parsed * @return the selectors parsed from the specified input source */ SelectorList parseSelectors(final InputSource source) { SelectorList selectors; try { final ErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler(); final CSSOMParser parser = new CSSOMParser(new SACParserCSS21()); parser.setErrorHandler(errorHandler); selectors = parser.parseSelectors(source); } catch (final Exception e) { LOG.error("Error parsing CSS selectors from '" + toString(source) + "': " + e.getMessage(), e); selectors = new SelectorListImpl(); } catch (final Error e) { // SACParser sometimes throws Error: "Missing return statement in function" LOG.error("Error parsing CSS selectors from '" + toString(source) + "': " + e.getMessage(), e); selectors = new SelectorListImpl(); } return selectors; }
/** * Parses the selectors at the specified input source. If anything at all goes wrong, this * method returns an empty selector list. * * @param source the source from which to retrieve the selectors to be parsed * @return the selectors parsed from the specified input source */ SelectorList parseSelectors(final InputSource source) { SelectorList selectors; try { final ErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler(); final CSSOMParser parser = new CSSOMParser(new SACParserCSS21()); parser.setErrorHandler(errorHandler); selectors = parser.parseSelectors(source); } catch (final Exception e) { LOG.error("Error parsing CSS selectors from '" + toString(source) + "': " + e.getMessage(), e); selectors = new SelectorListImpl(); } catch (final Error e) { // SACParser sometimes throws Error: "Missing return statement in function" LOG.error("Error parsing CSS selectors from '" + toString(source) + "': " + e.getMessage(), e); selectors = new SelectorListImpl(); } return selectors; }