public interface DOMConfiguration 
 
| org.w3c.dom.DOMConfiguration | 
DOMConfiguration界面表示文档的配置并维护一个可识别参数的表格。 使用该配置,可以更改Document.normalizeDocument()行为,例如用CDATASection节点替换Text节点或指定在请求验证Document时必须使用的模式类型。 DOMConfiguration对象也用于DOMParser和DOMSerializer接口中的[ DOM Level 3 Load and Save ]。
DOMConfiguration对象使用的参数名称在整个DOM级别3规范中定义。 名称不区分大小写。 为了避免可能的冲突,作为惯例,引用DOM规范之外定义的参数的名称应该是唯一的。 由于参数作为属性公开,因此建议使用名称' - '(HYPHEN-MINUS)后面的5.16节[Unicode]标识符,但不会由DOM实施实施。 DOM级别3核心实现需要识别本规范中定义的所有参数。 实现可能还需要一些参数值。 请参阅参数的定义以了解是否必须支持某个值。
注意:参数与SAX2 [ SAX ]中使用的特征和属性相似。
DOM中定义的以下参数列表:
"canonical-form" 
     true 
       DocumentType node (if any) from the tree, or removing superfluous namespace declarations from each element. Note that this is limited to what can be represented in the DOM; in particular, there is no way to specify the order of the attributes in the DOM. In addition, Setting this parameter to 
        true will also set the state of the parameters listed below. Later changes to the state of one of those parameters will revert "canonical-form" back to 
        false. Parameters set to 
        false: "entities", " normalize-characters", "cdata-sections". Parameters set to 
        true: "namespaces", "namespace-declarations", "well-formed", "element-content-whitespace". Other parameters are not changed unless explicitly specified in the description of the parameters. 
       false 
       "cdata-sections" 
     true 
       CDATASection nodes in the document. 
       false 
       CDATASection nodes in the document into 
        Text nodes. The new 
        Text node is then combined with any adjacent 
        Text node. 
       "check-character-normalization" 
     true 
       DOMError.type equals to "check-character-normalization-failure" is issued. 
       false 
       "comments" 
     true 
       Comment nodes in the document. 
       false 
       Comment nodes in the document. 
       "datatype-normalization" 
     true 
       true. Having this parameter activated when "validate" is 
        false has no effect and no schema-normalization will happen. 
        注意:由于文档包含XML 1.0处理的结果,因此此参数不适用于[ XML 1.0 ]的第3.3.3节中定义的属性值标准化,仅适用于文档类型定义(DTD)以外的模式语言。
false 
       "element-content-whitespace" 
     true 
       false 
       Text nodes that contain whitespaces in element content, as described in 
         [element content whitespace]. The implementation is expected to use the attribute 
        Text.isElementContentWhitespace to determine if a 
        Text node should be discarded or not. 
       "entities" 
     true 
       EntityReference nodes in the document. 
       false 
       EntityReference nodes from the document, putting the entity expansions directly in their place. 
        Text nodes are normalized, as defined in 
        Node.normalize. Only 
         unexpanded entity references are kept in the document. 
       注意:此参数不影响 Entity节点。
"error-handler" 
     DOMErrorHandler object. If an error is encountered in the document, the implementation will call back the 
      DOMErrorHandler registered using this parameter. The implementation may provide a default 
      DOMErrorHandler object. When called, 
      DOMError.relatedData will contain the closest node to where the error occurred. If the implementation is unable to determine the node where the error occurs, 
      DOMError.relatedData will contain the 
      Document node. Mutations to the document from within an error handler will result in implementation dependent behavior. 
     "infoset" 
     true 
       false: " validate-if-schema", "entities", "datatype-normalization", "cdata-sections ".This forces the following parameters to 
        true: " namespace-declarations", "well-formed", "element-content-whitespace", " comments", "namespaces".Other parameters are not changed unless explicitly specified in the description of the parameters. Note that querying this parameter with 
        getParameter returns 
        true only if the individual parameters specified above are appropriately set. 
       false 
       infoset to 
        false has no effect. 
       "namespaces" 
     true 
       false 
       "namespace-declarations" 
     false. 
      true 
       false 
       Node.prefix) are retained even if this parameter is set to 
        false. 
       "normalize-characters" 
     true 
       false 
       "schema-location" 
     DOMString object containing a list of URIs, separated by whitespaces (characters matching the 
      nonterminal production S defined in section 2.3 [ 
      XML 1.0]), that represents the schemas against which validation should occur, i.e. the current schema. The types of schemas referenced in this list must match the type specified with 
      schema-type, otherwise the behavior of an implementation is undefined. The schemas specified using this property take precedence to the schema information specified in the document itself. For namespace aware schema, if a schema specified using this property and a schema specified in the document instance (i.e. using the 
      schemaLocation attribute) in a schema document (i.e. using schema 
      import mechanisms) share the same 
      targetNamespace, the schema specified by the user using this property will be used. If two schemas specified using this property share the same 
      targetNamespace or have no namespace, the behavior is implementation dependent. If no location has been provided, this parameter is 
      null. 
      注意:除非设置了“模式类型”参数值,否则将忽略"schema-location"参数。 强烈建议设置Document.documentURI以便实现可以成功解析任何引用的外部实体。
"schema-type" 
     DOMString object containing an absolute URI and representing the type of the schema language used to validate a document against. Note that no lexical checking is done on the absolute URI. If this parameter is not set, a default value may be provided by the implementation, based on the schema languages supported and on the schema language used at load time. If no value is provided, this parameter is 
      null. 
      注意:对于XML Schema [ XML Schema Part 1 ],应用程序必须使用值"http://www.w3.org/2001/XMLSchema" 。 对于XML DTD [ XML 1.0 ],应用程序必须使用值"http://www.w3.org/TR/REC-xml" 。 其他模式语言超出了W3C的范围,因此应该推荐绝对URI以使用此方法。
"split-cdata-sections" 
     true 
       DOMError.type equals to 
        "cdata-sections-splitted" and 
        DOMError.relatedData equals to the first 
        CDATASection node in document order resulting from the split. 
       false 
       CDATASection contains an unrepresentable character. 
       "validate" 
     true 
       true. This parameter will reevaluate: 
        Attr.specified equals to false, as specified in the description of the Attr interface; Text.isElementContentWhitespace for all Text nodes; Attr.isId for all Attr nodes; Element.schemaTypeInfo and Attr.schemaTypeInfo. 注意: “validate-if-schema”和“validate”是互斥的,将其中一个设置为true会将另一个设置为false 。 验证文档时,应用程序还应该考虑将参数“格式良好”设置为true (该选项的默认值)。
false 
       true . 
       "validate-if-schema" 
     true 
       true. 
        注意: “validate-if-schema”和“validate”是互斥的,将其中一个设置为 true会将另一个设置为 false 。
false 
       true. 
       "well-formed" 
     true 
       Document.xmlVersion: 
        Node.nodeName contains invalid characters according to its node type and generate a DOMError of type "wf-invalid-character-in-node-name", with a DOMError.SEVERITY_ERROR severity, if necessary; Attr, Element, Comment, Text, CDATASection nodes for invalid characters and generate a DOMError of type "wf-invalid-character", with a DOMError.SEVERITY_ERROR severity, if necessary; ProcessingInstruction nodes for invalid characters and generate a DOMError of type "wf-invalid-character", with a DOMError.SEVERITY_ERROR severity, if necessary; false 
       与实体关联的系统标识符的解析使用Document.documentURI完成。 但是,当DOM实现支持[ DOM Level 3 Load and Save ]中定义的功能“LS”时,参数“resource-resolver”也可以用于连接到Document节点的DOMConfiguration对象。 如果设置了此参数,则Document.normalizeDocument()将调用资源解析器,而不是使用Document.documentURI 。
另见 Document Object Model (DOM) Level 3 Core Specification 。
| Public methods | |
|---|---|
|  abstract boolean |  canSetParameter(String name, Object value) 检查是否支持将参数设置为特定值。 | 
|  abstract Object |  getParameter(String name) 如果已知,则返回参数的值。 | 
|  abstract DOMStringList |  getParameterNames() 这个  | 
|  abstract void |  setParameter(String name, Object value) 设置参数的值。 | 
boolean canSetParameter (String name, Object value)
检查是否支持将参数设置为特定值。
| Parameters | |
|---|---|
| name | String: The name of the parameter to check. | 
| value | Object: An object. ifnull, the returned value istrue. | 
| Returns | |
|---|---|
| boolean | trueif the parameter could be successfully set to the specified value, orfalseif the parameter is not recognized or the requested value is not supported. This does not change the current value of the parameter itself. | 
Object getParameter (String name)
如果已知,则返回参数的值。
| Parameters | |
|---|---|
| name | String: The name of the parameter. | 
| Returns | |
|---|---|
| Object | The current object associated with the specified parameter or nullif no object has been associated or if the parameter is not supported. | 
| Throws | |
|---|---|
| DOMException | NOT_FOUND_ERR: Raised when the parameter name is not recognized. | 
DOMStringList getParameterNames ()
此DOMConfiguration对象支持的参数的列表,并且应用程序可以为其设置至少一个值。 请注意,该列表还可以包含在本规范之外定义的参数名称。
| Returns | |
|---|---|
| DOMStringList | |
void setParameter (String name, Object value)
设置参数的值。
| Parameters | |
|---|---|
| name | String: The name of the parameter to set. | 
| value | Object: The new value ornullif the user wishes to unset the parameter. While the type of the value parameter is defined asDOMUserData, the object type must match the type defined by the definition of the parameter. For example, if the parameter is "error-handler", the value must be of typeDOMErrorHandler. | 
| Throws | |
|---|---|
| DOMException | NOT_FOUND_ERR: Raised when the parameter name is not recognized. NOT_SUPPORTED_ERR: Raised when the parameter name is recognized but the requested value cannot be set. TYPE_MISMATCH_ERR: Raised if the value type for this parameter name is incompatible with the expected value type. |