Package org.w3c.css.sac

Examples of org.w3c.css.sac.Parser


      return createStylesheet(new InputSource(css));
   }

   private static StylesheetObject createStylesheet(InputSource source) throws IOException, CSSException
   {
      Parser parser = ParserFactory.createParser();
      ModelBuilder builder = new ModelBuilder();
      parser.setDocumentHandler(builder);
      parser.parseStyleSheet(source);
      return builder.getStylesheet();
   }
View Full Code Here


    /**
     * Creates new CSSEngine and attach it to the document.
     */
    public CSSEngine createCSSEngine(SVGOMDocument doc, CSSContext ctx) {
        String pn = XMLResourceDescriptor.getCSSParserClassName();
        Parser p;
        try {
            p = (Parser)Class.forName(pn).newInstance();
        } catch (ClassNotFoundException e) {
            throw new DOMException(DOMException.INVALID_ACCESS_ERR,
                                   formatMessage("css.parser.class",
View Full Code Here

        if (customValueManagers == null && customShorthandManagers == null) {
            return super.createCSSEngine(doc, ctx);
        }

        String pn = XMLResourceDescriptor.getCSSParserClassName();
        Parser p;
        try {
            p = (Parser)Class.forName(pn).newInstance();
        } catch (ClassNotFoundException e) {
            throw new DOMException(DOMException.INVALID_ACCESS_ERR,
                                   formatMessage("css.parser.class",
View Full Code Here

     * Creates new CSSEngine and attach it to the document.
     */
    public CSSEngine createCSSEngine(AbstractStylableDocument doc,
                                     CSSContext ctx) {
        String pn = XMLResourceDescriptor.getCSSParserClassName();
        Parser p;
        try {
            p = (Parser)Class.forName(pn).newInstance();
        } catch (ClassNotFoundException e) {
            throw new DOMException(DOMException.INVALID_ACCESS_ERR,
                                   formatMessage("css.parser.class",
View Full Code Here

  }

  private String parse() throws IOException {
    InputStreamReader reader2 = new InputStreamReader(_cssUrl.openStream());
    InputSource source2 = new InputSource(reader2);
    Parser p = new SACParserCSS2();
    CssDocumentHandlerImpl handler = new CssDocumentHandlerImpl(_context,
        _parentBundle);
    p.setDocumentHandler(handler);
    p.parseStyleSheet(source2);
    reader2.close();
    return handler.getResults();
  }
View Full Code Here

  private String parse(ResourceService resourceService, URL url)
      throws IOException {
    InputStreamReader reader2 = new InputStreamReader(url.openStream());
    InputSource source2 = new InputSource(reader2);
    Parser p = new SACParserCSS2();
    CssDocumentHandler handler = new CssDocumentHandler(resourceService,_locale);
    p.setDocumentHandler(handler);
    p.parseStyleSheet(source2);
    reader2.close();
    return handler.getResults();
  }
View Full Code Here

  private void parse(String snippet) throws CSSException {

    try {
      BufferedReader reader = new BufferedReader(new StringReader(snippet));
      InputSource source = new InputSource(reader);
      Parser p = new SACParserCSS2();
      p.setDocumentHandler(this);
      p.parseStyleSheet(source);
      reader.close();
    } catch (IOException ex) {
      throw new CSSException(ex);
    }
  }
View Full Code Here

     * Parses a style sheet.
     */
    public static void parseStyleSheet(CSSOMStyleSheet ss, String uri)
        throws DOMException {
  try {
      Parser parser = ss.getParser();
      InputSource is = new InputSource(uri);
      parser.setSelectorFactory(AbstractCSSRule.SELECTOR_FACTORY);
      parser.setConditionFactory(AbstractCSSRule.CONDITION_FACTORY);
      parser.setDocumentHandler(new CSSDocumentHandler(ss, true));
      parser.parseStyleSheet(is);
  } catch (DOMException e) {
      throw e;
  } catch (Exception e) {
      throw CSSDOMExceptionFactory.createDOMException
    (DOMException.SYNTAX_ERR,
View Full Code Here

     * Parses a set of rules from its CSS text.
     */
    public static void parseRules(CSSOMStyleSheet ss, String rules)
        throws DOMException {
  try {
      Parser parser = ss.getParser();
      parser.setSelectorFactory(AbstractCSSRule.SELECTOR_FACTORY);
      parser.setConditionFactory(AbstractCSSRule.CONDITION_FACTORY);
      parser.setDocumentHandler(new CSSDocumentHandler(ss, true));
      parser.parseStyleSheet(new InputSource(new StringReader(rules)));
  } catch (DOMException e) {
      throw e;
  } catch (Exception e) {
      throw CSSDOMExceptionFactory.createDOMException
    (DOMException.SYNTAX_ERR,
View Full Code Here

     */
    public static CSSRule parseRule(CSSOMStyleSheet ss, String rule)
        throws DOMException {
  try {
      CSSDocumentHandler ssh;
      Parser parser = ss.getParser();
      parser.setSelectorFactory(AbstractCSSRule.SELECTOR_FACTORY);
      parser.setConditionFactory(AbstractCSSRule.CONDITION_FACTORY);
      parser.setDocumentHandler(ssh = new CSSDocumentHandler(ss, false));
      parser.parseRule(new InputSource(new StringReader(rule)));
      return ssh.currentRule;
  } catch (DOMException e) {
      throw e;
  } catch (Exception e) {
      throw CSSDOMExceptionFactory.createDOMException
View Full Code Here

TOP

Related Classes of org.w3c.css.sac.Parser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.