MSXML中 validateOnLoad 和 validateOnParse 有什么区别啊

zhghl 2004-11-15 05:19:03
多谢指点,应该怎么用呢,能否举个例子.
...全文
92 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
redez 2004-11-16
  • 打赏
  • 举报
回复
validateOnLoad:
Indicates whether the schema will be compiled and validated when it is loaded into the schema cache,The validateOnLoad Property must be set to false before any schemas that are not to be validated are loaded into the schema cache.
validateOnParse:
Indicates whether the parser should validate this document,If True, validates during parsing. If False, parses only for well-formed XML
zhghl 2004-11-16
  • 打赏
  • 举报
回复
谢谢,能解释一下吗
孟子E章 2004-11-16
  • 打赏
  • 举报
回复
validateOnParse
标明解析器是否要对文档进行验证


validateOnLoad

Indicates whether the schema will be compiled and validated when it is loaded into the schema cache. The validateOnLoad Property must be set to false before any schemas that are not to be validated are loaded into the schema cache.

redez 2004-11-15
  • 打赏
  • 举报
回复
validateOnLoad例子:

Set oSchemaCache = CreateObject("Msxml2.XMLSchemaCache.4.0")
Set oAnnotationDoc = CreateObject("Msxml2.DOMDocument.4.0")

' Load the schema.
nsTarget="http://www.example.microsoft.com/po"

' Setting validateOnLoad to true is optional; true is the default value.
oSchemaCache.validateOnLoad = true
oSchemaCache.add "urn1", schema1 ' Validated on add.
oSchemaCache.add "urn2", schema2 ' Validated on add.
oSchemaCache.validateOnLoad = false
oSchemaCache.add "urn3", schema3 ' Not validated yet.
oSchemaCache.add "urn4", schema4 ' Not validated yet.
' Schema3 and schema4 are validated now. Schema1 and schema2 are not validated now, because they already were.

oSchemaCache.validate

validateOnParse 例子:

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
xmlDoc.async = false;
xmlDoc.validateOnParse = true;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode != 0) {
var myErr = xmlDoc.parseError;
WScript.Echo("You have error " + myErr.reason);
}

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧