Hi, I have a problem regarding the parsing of css. I followed the instructions as they are described here. My code looks like the following:
CSSOMParser parser = new CSSOMParser();
InputSource source = new InputSource(new StringReader("p {color:#000000}"));
CSSStyleSheet sheet = parser.parseStyleSheet(source, null, null);
However the last line throws me the following exception:
java.util.EmptyStackException
at java.util.Stack.peek(Stack.java:85)
at java.util.Stack.pop(Stack.java:67)
at com.steadystate.css.parser.CSSOMParser$CSSOMHandler.endDocument(CSSOMParser.java:269)
at com.steadystate.css.parser.AbstractSACParser.handleEndDocument(AbstractSACParser.java:449)
at com.steadystate.css.parser.SACParserCSS21.styleSheet(SACParserCSS21.java:54)
at com.steadystate.css.parser.AbstractSACParser.parseStyleSheet(AbstractSACParser.java:277)
at com.steadystate.css.parser.SACParserCSS21.parseStyleSheet(SACParserCSS21.java:21)
at com.steadystate.css.parser.CSSOMParser.parseStyleSheet(CSSOMParser.java:144)
Thanks in advance
EDIT:
I found the problem, the parser was running on a different ClassLoader, therefore it was not able to work. This Question can be closed.
Last edit: Hayri Bakici 2013-04-05
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I have a problem regarding the parsing of css. I followed the instructions as they are described here. My code looks like the following:
CSSOMParser parser = new CSSOMParser();
InputSource source = new InputSource(new StringReader("p {color:#000000}"));
CSSStyleSheet sheet = parser.parseStyleSheet(source, null, null);
However the last line throws me the following exception:
java.util.EmptyStackException
at java.util.Stack.peek(Stack.java:85)
at java.util.Stack.pop(Stack.java:67)
at com.steadystate.css.parser.CSSOMParser$CSSOMHandler.endDocument(CSSOMParser.java:269)
at com.steadystate.css.parser.AbstractSACParser.handleEndDocument(AbstractSACParser.java:449)
at com.steadystate.css.parser.SACParserCSS21.styleSheet(SACParserCSS21.java:54)
at com.steadystate.css.parser.AbstractSACParser.parseStyleSheet(AbstractSACParser.java:277)
at com.steadystate.css.parser.SACParserCSS21.parseStyleSheet(SACParserCSS21.java:21)
at com.steadystate.css.parser.CSSOMParser.parseStyleSheet(CSSOMParser.java:144)
Thanks in advance
EDIT:
I found the problem, the parser was running on a different ClassLoader, therefore it was not able to work. This Question can be closed.
Last edit: Hayri Bakici 2013-04-05
I'm getting the same issue. But not sure what was your ClassLoader issue. I don't see any ClassLoader here.
@Hayri: can you give more details?
Okay, I found out that CSSOMParser is not threadsafed. Fixed by using separate CSSOMParser instance each time.