Example #1
0
  private static StyleSheet jParseCSS2(
      final org.w3c.dom.Node ownerNode,
      final String cssURI,
      final String processedText,
      final UserAgentContext bcontext) {

    CSSFactory.setAutoImportMedia(new MediaSpecNone());
    try {
      final URL base = new URL(cssURI);
      return CSSParserFactory.getInstance()
          .parse(
              processedText, new SafeNetworkProcessor(bcontext), null, SourceType.EMBEDDED, base);
    } catch (IOException | CSSException e) {
      logger.log(Level.SEVERE, "Unable to parse CSS. URI=[" + cssURI + "].", e);
      return getEmptyStyleSheet();
    }
  }
Example #2
0
 public static StyleSheet jParseInlineStyle(
     final String style,
     final String encoding,
     final HTMLElementImpl element,
     final boolean inlinePriority) {
   try {
     return CSSParserFactory.getInstance()
         .parse(
             style,
             new SafeNetworkProcessor(null),
             null,
             SourceType.INLINE,
             element,
             inlinePriority,
             element.getDocumentURL());
   } catch (IOException | CSSException e) {
     logger.log(Level.SEVERE, "Unable to parse CSS. CSS=[" + style + "].", e);
     return getEmptyStyleSheet();
   }
 }