1

解析 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 元素的分析吗?(我相信它会,但希望它不会)

提前致谢..

4

2 回答 2

1

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

于 2011-08-03T11:02:04.540 回答
-1

解析时必须转义字符。Apache 有StringEscapeUtils可以帮助你的课程。我认为你必须使用StringEscapeUtils.escapeHTML(readedText);由于 html 和 css 语法更相似。

问候!

于 2011-08-03T10:58:00.400 回答