Package org.w3c.css.sac

Examples of org.w3c.css.sac.Parser


  {
    final Configuration config = ClassicEngineBoot.getInstance().getGlobalConfig();
    final String parserClass = config.getConfigProperty("org.w3c.css.sac.Parser");
    if (parserClass != null)
    {
      final Parser p = ObjectUtilities.loadAndInstantiate(parserClass, CSSParserFactory.class, Parser.class);
      if (p != null)
      {
        p.setConditionFactory(new FixNamespaceConditionFactory(new CSSConditionFactory(),namespaceCollection));
        p.setSelectorFactory(new FixNamespaceSelectorFactory(new CSSSelectorFactory(),namespaceCollection));
        return p;
      }
    }
    try
    {
      final Parser p = new ParserFactory().makeParser();
      if (p == null)
      {
        return null;
      }
      p.setConditionFactory(new FixNamespaceConditionFactory(new CSSConditionFactory(),namespaceCollection));
      p.setSelectorFactory(new FixNamespaceSelectorFactory(new CSSSelectorFactory(),namespaceCollection));
      return p;
    }
    catch (Exception e)
    {
      e.printStackTrace();
View Full Code Here


  this.href = href;
  this.media = media;
  CSSOMStyleSheet ss = (CSSOMStyleSheet)parent;
  parser = ss.getParser();
  try {
      Parser p = CSSDocumentHandler.createParser();
      styleSheet = new CSSOMStyleSheet(null,
               parent,
               href,
               null,
               media,
View Full Code Here

      for (int i = 0; i < m.getLength(); i++) {
    media.appendMedium(m.item(i));
      }
      try {
    CSSOMStyleSheet ss = (CSSOMStyleSheet)getParentStyleSheet();
    Parser p = CSSDocumentHandler.createParser();
    styleSheet = new CSSOMStyleSheet(null,
             ss,
             href,
             null,
             media,
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, uri, true));
      parser.parseStyleSheet(is);
  } catch (Exception e) {
            e.printStackTrace();
            String m = e.getMessage();
      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, null, true));
      parser.parseStyleSheet(new InputSource(new StringReader(rules)));
  } catch (DOMException e) {
      throw CSSDOMExceptionFactory.createDOMException
    (DOMException.SYNTAX_ERR,
     "rules.syntax.error",
     new Object[] { rules + "\n" + e.getMessage() });
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, null, false));
      parser.parseRule(new InputSource(new StringReader(rule)));
      return ssh.currentRule;
  } catch (DOMException e) {
      throw CSSDOMExceptionFactory.createDOMException
    (DOMException.SYNTAX_ERR,
     "rule.syntax.error",
View Full Code Here

    /**
     * Creates a new CSSStyleDeclaration object.
     */
    public CSSOMStyleDeclaration() {
  try {
      Parser p = CSSDocumentHandler.createParser();
      parser = ExtendedParserWrapper.wrap(p);
  } catch (Exception e) {
      throw new RuntimeException(e.getMessage());
  }
    }
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

  {

    final ResourceManager resourceManager= new ResourceManager();
    resourceManager.registerDefaults();

    final Parser parser = CSSParserFactory.getInstance().createCSSParser();
    final StyleSheetHandler handler = new StyleSheetHandler();
    handler.init (resourceManager, null, 0, StyleKeyRegistry.getRegistry(), null);
    parser.setDocumentHandler(handler);
    final String selector = ".bordered";
    final SelectorList sl =
            parser.parseSelectors(new StringInputSource (selector, new URL("http://localhost")));
    System.exit(0);
  }
View Full Code Here

      throw new NullPointerException();
    }

    try
    {
      final Parser parser = getParser();
      synchronized(parser)
      {
        final StyleSheetHandler handler = new StyleSheetHandler();
        handler.init
            (resourceManager, baseURL, -1, StyleKeyRegistry.getRegistry(), null);

        setupNamespaces(namespaces, handler);

        final InputSource source = new InputSource();
        source.setCharacterStream(new StringReader(selector));

        handler.initParseContext(source);
        handler.setStyleRule(new CSSStyleRule(null, null));
        parser.setDocumentHandler(handler);

        final SelectorList selectorList = parser.parseSelectors(source);
        CSSParserContext.getContext().destroy();
        return selectorList;
      }
    }
    catch (Exception e)
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.