w3c Jigsaw Powered
CSS
Validator

CSS Validator version 2.0 : How to add CSS properties in this validator ?

In first, you should create your properties.

To do this, You should extend the class CSS.Properties.CssProperty. If you have some macros, see CSS.Properties.ACssCueBefore for an example.

An example for the name of a property : CSS2.Printing.CssPageBreakBefore

Then, you should implements the interface org.w3c.css.parser.CssStyle. For an example, you can see org.w3c.css.aural.ACssStyle. In this example, I added aural cascading style sheet to cascading style sheet level 1, so I extends the style Css1Style that implements the CssStyle. Be careful, you must have a public constructor with no parameters in your CssStyle !

An example for the name of your style : CSS2.Printing.PCssStyle

Create two configuration properties file :

  1. Config.properties
    # My parser config :
    style : CSS2.Printing.PCssStyle
    properties: CSS2Printing.properties
    # Note : the file CSS2Printing.properties should be in your style directory.
    
    # Activate the CSS2 parser
    extended-parser : true
    	
  2. CS2Printing.properties
    # A property
    # Note : if you want to reuse CSS1 properties, you should add all properties !
    #        For an example, see AuralProperties.properties
    page-break-before : CSS2.Printing.CssPageBreakBefore
    	

Now you are ready to parse your properties.

Finally, You should say where the parser can find your properties. This is a sample code to parse your owns properties :

import java.util.Properties;
import java.net.URL;

import org.w3c.css.parser.CssFouffa;
import org.w3c.css.css.StyleSheetParser;
import org.w3c.css.css.StyleSheetOrigin;

import CSS2.Printing.PCssStyle;

class MyStartUp {

 public static void main(String[] args) {

  Properties properties = new Properties();
  try {
   Properties config = new Properties();

   // try to load the file
   URL url = PCssStyle.class.getResource("CSS2Printing.properties");

   config.load(url.openStream());

   // set the parser
   CssFouffa.loadConfig(config);

  } catch (Exception e) {
   System.err.println("MyStartUp: couldn't load properties");
   System.err.println("  " + e.toString() );
   System.exit(1);
  }

  // now the parser is ready !

  // create a parser
  StyleSheetParser parser = new StyleSheetParser();

  // parse an URL
  parser.parseURL(new URL("http://www.w3.org/Style"), StyleSheetOrigin.AUTHOR);

  // output the result
  StyleSheetGenerator style = 
   new StyleSheetGenerator("My example",           // title
                           parser.getStyleSheet(), // get the style sheet
                           "text");                // output format
  style.print(System.out);
 }
}

    

There is an example for a new package for CSS2. In this example, I reuse Aural properties.


made with CSS
validator-css