Rhino JS,声明错误?
我正在尝试使用 Rhino 的 CSSParser (0.9.5)。文档似乎缺乏,但我发现 这个示例代码对我来说很有意义。
但是当我尝试使用Rhino 1.7R2时:
js> var is = new java.io.FileInputStream("style.css");
js> var r = new java.io.InputStreamReader(is);
js> var source = new Packages.org.w3c.css.sac.InputSource(r);
js> var parser = new Packages.com.steadystate.css.parser.CSSOMParser();
js> parser
com.steadystate.css.parser.CSSOMParser@d24e3f
js> parser.parseStyleDeclaration
function parseStyleDeclaration() {/*
org.w3c.dom.css.CSSStyleDeclaration parseStyleDeclaration(org.w3c.css.sac.InputSource)
void parseStyleDeclaration(org.w3c.dom.css.CSSStyleDeclaration,org.w3c.css.sac.InputSource)
*/}
js> parser.parseStyleDeclaration(source);
null [1:4] Error in declaration. Invalid token ".". Was expecting one of: <S>, ":".
由于有两种方法可以调用parseStyleDeclaration,所以我还尝试了另一种:(
与上面相同,但是)
js> var style = new Packages.com.steadystate.css.dom.CSSStyleDeclarationImpl();
js> parser.parseStyleDeclaration(style, source);
null [1:4] Error in declaration. Invalid token ".". Was expecting one of: <S>, ":".
这可能是我忘记的简单事情。但什么?
I'm trying to use CSSParser (0.9.5) from Rhino. The documentation seems to be lacking, but I found this sample code that makes sense to me.
But when I try, with Rhino 1.7R2:
js> var is = new java.io.FileInputStream("style.css");
js> var r = new java.io.InputStreamReader(is);
js> var source = new Packages.org.w3c.css.sac.InputSource(r);
js> var parser = new Packages.com.steadystate.css.parser.CSSOMParser();
js> parser
com.steadystate.css.parser.CSSOMParser@d24e3f
js> parser.parseStyleDeclaration
function parseStyleDeclaration() {/*
org.w3c.dom.css.CSSStyleDeclaration parseStyleDeclaration(org.w3c.css.sac.InputSource)
void parseStyleDeclaration(org.w3c.dom.css.CSSStyleDeclaration,org.w3c.css.sac.InputSource)
*/}
js> parser.parseStyleDeclaration(source);
null [1:4] Error in declaration. Invalid token ".". Was expecting one of: <S>, ":".
Since there's 2 ways to call parseStyleDeclaration, I also tried the other one:
(same as above, but then)
js> var style = new Packages.com.steadystate.css.dom.CSSStyleDeclarationImpl();
js> parser.parseStyleDeclaration(style, source);
null [1:4] Error in declaration. Invalid token ".". Was expecting one of: <S>, ":".
It's probably something simple I'm forgetting. But what?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没关系,我是个白痴。
这是 CSSParser 错误,而不是 Rhino 错误。
Never mind, I'm an idiot.
It's a CSSParser error, not a Rhino error.