我计划编写一个 SAX2 XML 解析器,并且希望支持尽可能多的标准选项。然而,我真的很挠头,试图理解
http://xml.org/sax/properties/xml-string
属性应该是什么。文档(来自 org.xml.sax 包的 JavaDocs)内容如下:
仅在解析器回调期间可读,这公开了负责当前事件的 TBS 字符块。
“TBS 块”到底是什么?
我尝试过谷歌搜索“tbs chunk”、“sax”和“xml-string”的各种组合,但没有找到任何有用的结果。主要是关于如何使用 SAX 解析 XML 块的页面。肯定有人比我拥有更好的 Google 功能吗?
看来你不是唯一不知道这意味着什么的人。
JDK 包含几个实现解析器配置的类:
DOMConfigurationImpl
BasicParserConfiguration
XML11Configuration
XML11DTDConfiguration
XML11NonValidatingConfiguration
所有这些类都为
xml-string
属性指定相同的行为:
// special cases
if (propertyId.startsWith(Constants.SAX_PROPERTY_PREFIX)) {
final int suffixLength = propertyId.length() - Constants.SAX_PROPERTY_PREFIX.length();
//
// http://xml.org/sax/properties/xml-string
// Value type: String
// Access: read-only
// Get the literal string of characters associated with the
// current event. If the parser recognises and supports this
// property but is not currently parsing text, it should return
// null (this is a good way to check for availability before the
// parse begins).
//
if (suffixLength == Constants.XML_STRING_PROPERTY.length() &&
propertyId.endsWith(Constants.XML_STRING_PROPERTY)) {
// REVISIT - we should probably ask xml-dev for a precise
// definition of what this is actually supposed to return, and
// in exactly which circumstances.
return PropertyState.NOT_SUPPORTED;
}
}
似乎即使是 JDK 的开发人员(或者,因为该代码是从 Apache Xerces 集成的)和 Apache Xerces 的开发人员也不知道这意味着什么。
请注意,据我所知,SAX API 不是由 JDK 开发人员指定的,而是由某些外部团体指定的。