有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

解析过程中的java CSSOMParser错误

我在解析css文件all.css时遇到以下错误

null [1:1763] Error in style rule. Invalid token "!". Was expecting one of: <S>, "}", ",", ";", "/", "+", "-", <HASH>, <STRING>, <URI>, <IMPORTANT_SYM>, "inherit", <EMS>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <DIMEN>, <PERCENTAGE>, <NUMBER>, "rgb(", <FUNCTION>, <IDENT>, <UNICODERANGE>.
null [1:1763] Ignoring the following declarations in this rule.
null [1:4352] Error in style rule. Invalid token "!". Was expecting one of: <S>, "}", ",", ";", "/", "+", "-", <HASH>, <STRING>, <URI>, <IMPORTANT_SYM>, "inherit", <EMS>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <DIMEN>, <PERCENTAGE>, <NUMBER>, "rgb(", <FUNCTION>, <IDENT>, <UNICODERANGE>.
null [1:4352] Ignoring the following declarations in this rule.
null [1:4435] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:4435] Ignoring the following declarations in this rule.
null [1:10349] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:10349] Ignoring the following declarations in this rule.
null [1:12131] Error in style rule. Invalid token "!". Was expecting one of: <S>, "}", ",", ";", "/", "+", "-", <HASH>, <STRING>, <URI>, <IMPORTANT_SYM>, "inherit", <EMS>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <DIMEN>, <PERCENTAGE>, <NUMBER>, "rgb(", <FUNCTION>, <IDENT>, <UNICODERANGE>.
null [1:12131] Ignoring the following declarations in this rule.
null [1:17335] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:17335] Ignoring the following declarations in this rule.
null [1:20115] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:20115] Ignoring the following declarations in this rule.
null [1:20499] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:20499] Ignoring the following declarations in this rule.
null [1:22593] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:22593] Ignoring the following declarations in this rule.
null [1:23137] Error in expression. Invalid token "=". Was expecting one of: <S>, ",", "/", "+", "-", <HASH>, <STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <DIMEN>, <PERCENTAGE>, <NUMBER>, "rgb(", <FUNCTION>, <IDENT>, <UNICODERANGE>.
null [1:27252] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:27252] Ignoring the following declarations in this rule.
null [1:28495] Error in style rule. Invalid token "!". Was expecting one of: <S>, "}", ",", ";", "/", "+", "-", <HASH>, <STRING>, <URI>, <IMPORTANT_SYM>, "inherit", <EMS>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <DIMEN>, <PERCENTAGE>, <NUMBER>, "rgb(", <FUNCTION>, <IDENT>, <UNICODERANGE>.
null [1:28495] Ignoring the following declarations in this rule.
null [1:32022] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:32022] Ignoring the following declarations in this rule.
null [1:33926] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:33926] Ignoring the following declarations in this rule.
null [1:34660] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:34660] Ignoring the following declarations in this rule.
null [1:36410] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:36410] Ignoring the following declarations in this rule.
null [1:36624] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:36624] Ignoring the following declarations in this rule.
null [1:37378] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:37378] Ignoring the following declarations in this rule.
null [1:39110] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:39110] Ignoring the following declarations in this rule.
null [1:40536] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:40536] Ignoring the following declarations in this rule.
null [1:41061] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:41061] Ignoring the following declarations in this rule.
null [1:41487] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:41487] Ignoring the following declarations in this rule.
null [1:45987] Error in expression. Invalid token "=". Was expecting one of: <S>, ",", "/", "+", "-", <HASH>, <STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <DIMEN>, <PERCENTAGE>, <NUMBER>, "rgb(", <FUNCTION>, <IDENT>, <UNICODERANGE>.
null [1:45992] Error in style rule. Invalid token "position". Was expecting one of: "}", ";".
null [1:45992] Ignoring the following declarations in this rule.
null [1:46761] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:46761] Ignoring the following declarations in this rule.
null [1:50353] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:50353] Ignoring the following declarations in this rule.
null [1:51070] Error in style rule. Invalid token "-". Was expecting one of: <S>, "}", ";", <IDENT>.
null [1:51070] Ignoring the following declarations in this rule.

它看起来与损坏的css标记有关。有人能澄清一下吗? 我使用文件中的css规则来计算html页面(链接到css)上的某些元素。这些错误是否会影响css规则的解析,从而影响网页上html元素的分析?(我肯定会,但希望不会)

提前谢谢


共 (2) 个答案

  1. # 1 楼答案

    解析时必须转义字符。Apache有StringEscapeUtils类可以帮助您。 我认为您必须使用StringEscapeUtils.escapeHTML(readedText);,因为html和css语法更相似

    你好

  2. # 2 楼答案

    可能是因为你使用了非标准的CSS规则,比如“!ie7”,或者是特定于供应商的属性,比如“-moz border radius”