Menu

#60 CSSParser is ignoring @Page rule

0.9.18
closed
RBRi
1
2016-05-23
2016-03-22
No

I'm trying to parse CSS text containing a @Page rule, but it is raising a runtime error and ignoring it completely.

The following piece of code ilustrates what I'm trying to do:

public class Main {
    public static void main(String arg[]) throws IOException {
        String str = "@page rotated { size : landscape }";
        InputSource source = new InputSource(new StringReader(str));
        CSSOMParser parser = new CSSOMParser(new SACParserCSS3());
        CSSStyleSheet sheet = parser.parseStyleSheet(source, null, null);
        CSSRuleList rules = sheet.getCssRules();
        for (int index = 0; index < rules.getLength(); ++index) {
            CSSRule rule = rules.item(index);
            System.out.println(rule.getCssText());
        }               
    }
}

Console Output:

null [1:7] Error in @page rule. (Invalid token "rotated". Was expecting one of: <S>, <LBRACE>, ":".)
null [1:7] Ignoring the whole rule.

Note: I suppressed import package declarations to make it shorter.

According to W3C CSS validator the style "@page rotated { size : landscape }" is fine.

See also: https://www.w3.org/TR/REC-CSS2/page.html (section 13.3.2)

Discussion

  • Fernando Costa

    Fernando Costa - 2016-03-22
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
    -I'm trying to parse CSS text containing a @Page rule in Java using CSSParser, but it is raising a runtime error and ignoring it completely.
    +I'm trying to parse CSS text containing a **@Page** rule in Java using CSSParser, but it is raising a runtime error and ignoring it completely.
    
     The following piece of code ilustrates what I'm trying to do:
    
    @@ -18,7 +18,7 @@
     }
     ~~~~
    
    -Console Output:
    +**Console Output:**
    
     ~~~~
     null [1:7] Error in @page rule. (Invalid token "rotated". Was expecting one of: <S>, <LBRACE>, ":".)
    
     
  • RBRi

    RBRi - 2016-03-22
    • status: open --> accepted
    • assigned_to: RBRi
     
  • RBRi

    RBRi - 2016-03-22

    Named page layouts are not supported at the moment (only pseudo pages are supported).
    Will try to add the support

     
  • Fernando Costa

    Fernando Costa - 2016-03-23
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
    -I'm trying to parse CSS text containing a **@Page** rule in Java using CSSParser, but it is raising a runtime error and ignoring it completely.
    +I'm trying to parse CSS text containing a **@Page** rule, but it is raising a runtime error and ignoring it completely.
    
     The following piece of code ilustrates what I'm trying to do:
    
     
  • RBRi

    RBRi - 2016-05-15

    Have added initial support for page selectors. Please check if this is sufficient for you.

     
  • RBRi

    RBRi - 2016-05-15
    • status: accepted --> pending
     
  • RBRi

    RBRi - 2016-05-23
    • status: pending --> closed
     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.