Scala XML 从节点到字符串的警告
Scala XML from Node to String warnings
我的问题是关于 scala.xml
以及从 Node
类型到 String
的转换(使用任何 buildString
或 toString
方法)。
当我对标准输出进行这样的转换时,我得到一个关于输入的警告列表,如下所示:
line 2 column 2 - Warning: unknown attribute "myAttribute1"
line 3 column 9 - Warning: unknown attribute "myAttribute2"
line 6 column 9 - Warning: unknown attribute "myAttribute3"
line 7 column 13 - Warning: unknown attribute "myAttribute4"
line 7 column 13 - Warning: unknown attribute "myAttribute5"
line 13 column 25 - Warning: <th> attribute "width" has invalid value "3%"
line 15 column 36 - Warning: <th> attribute "width" has invalid value "5%"
line 17 column 36 - Warning: <th> attribute "width" has invalid value "3%"
line 19 column 36 - Warning: <th> attribute "width" has invalid value "15%"
line 21 column 36 - Warning: <th> attribute "width" has invalid value "3%"
line 23 column 36 - Warning: <th> attribute "width" has invalid value "3%"
line 25 column 36 - Warning: <th> attribute "width" has invalid value "3%"
line 27 column 36 - Warning: <th> attribute "width" has invalid value "3%"
line 29 column 36 - Warning: <th> attribute "width" has invalid value "3%"
line 35 column 22 - Warning: unknown attribute "data-col-count"
line 41 column 15 - Warning: inserting missing 'title' element
InputStream: Document content looks like HTML 4.01 Transitional
18 warnings, no errors were found!
The table summary attribute should be used to describe
the table structure. It is very helpful for people using
non-visual browsers. The scope and headers attributes for
table cells are useful for specifying which headers apply
to each table cell, enabling non-visual browsers to provide
a meaningful context for each cell.
For further advice on how to make your pages accessible
see "http://www.w3.org/WAI/GL". You may also want to try
"http://www.cast.org/bobby/" which is a free Web-based
service for checking URLs for accessibility.
所以,我的问题是是否有办法摆脱这样的输出。
生成这个的代码只是:
data.buildString(true).getBytes(StandardCharsets.UTF_8)
其中数据是 Scala.xml.Node
谢谢
编辑
我试图从 Node
解析到 String
并返回到 REPL,但我没有收到任何警告。
为了解析,我使用自定义对象从 scala.xml 扩展 XMLLooader
,并带有 SAXParser
和 setValidation(false)
。然后我只使用 loadString(input)
来获取我的节点。
查看 SAXParser
的文档我在这里结束:https://docs.oracle.com/javase/7/docs/api/org/xml/sax/helpers/DefaultHandler.html#warning(org.xml.sax.SAXParseException) 它说,在默认情况下没有为警告提供操作。
看起来您的输出来自 JTidy,如 this question about removing warnings 中所述,或者可能是其他 'tidy' 库。
当我尝试你的线路时:
data.buildString(true).getBytes(StandardCharsets.UTF_8)
它没有给我任何你得到的输出,也许是程序的另一部分导致了这个?
我的问题是关于 scala.xml
以及从 Node
类型到 String
的转换(使用任何 buildString
或 toString
方法)。
当我对标准输出进行这样的转换时,我得到一个关于输入的警告列表,如下所示:
line 2 column 2 - Warning: unknown attribute "myAttribute1"
line 3 column 9 - Warning: unknown attribute "myAttribute2"
line 6 column 9 - Warning: unknown attribute "myAttribute3"
line 7 column 13 - Warning: unknown attribute "myAttribute4"
line 7 column 13 - Warning: unknown attribute "myAttribute5"
line 13 column 25 - Warning: <th> attribute "width" has invalid value "3%"
line 15 column 36 - Warning: <th> attribute "width" has invalid value "5%"
line 17 column 36 - Warning: <th> attribute "width" has invalid value "3%"
line 19 column 36 - Warning: <th> attribute "width" has invalid value "15%"
line 21 column 36 - Warning: <th> attribute "width" has invalid value "3%"
line 23 column 36 - Warning: <th> attribute "width" has invalid value "3%"
line 25 column 36 - Warning: <th> attribute "width" has invalid value "3%"
line 27 column 36 - Warning: <th> attribute "width" has invalid value "3%"
line 29 column 36 - Warning: <th> attribute "width" has invalid value "3%"
line 35 column 22 - Warning: unknown attribute "data-col-count"
line 41 column 15 - Warning: inserting missing 'title' element
InputStream: Document content looks like HTML 4.01 Transitional
18 warnings, no errors were found!
The table summary attribute should be used to describe
the table structure. It is very helpful for people using
non-visual browsers. The scope and headers attributes for
table cells are useful for specifying which headers apply
to each table cell, enabling non-visual browsers to provide
a meaningful context for each cell.
For further advice on how to make your pages accessible
see "http://www.w3.org/WAI/GL". You may also want to try
"http://www.cast.org/bobby/" which is a free Web-based
service for checking URLs for accessibility.
所以,我的问题是是否有办法摆脱这样的输出。 生成这个的代码只是:
data.buildString(true).getBytes(StandardCharsets.UTF_8)
其中数据是 Scala.xml.Node
谢谢
编辑
我试图从 Node
解析到 String
并返回到 REPL,但我没有收到任何警告。
为了解析,我使用自定义对象从 scala.xml 扩展 XMLLooader
,并带有 SAXParser
和 setValidation(false)
。然后我只使用 loadString(input)
来获取我的节点。
查看 SAXParser
的文档我在这里结束:https://docs.oracle.com/javase/7/docs/api/org/xml/sax/helpers/DefaultHandler.html#warning(org.xml.sax.SAXParseException) 它说,在默认情况下没有为警告提供操作。
看起来您的输出来自 JTidy,如 this question about removing warnings 中所述,或者可能是其他 'tidy' 库。
当我尝试你的线路时:
data.buildString(true).getBytes(StandardCharsets.UTF_8)
它没有给我任何你得到的输出,也许是程序的另一部分导致了这个?