如题
最好能报错
最好能报错
解决方案 »
- 可逆加密算法有哪些?
- 求fastreport delphi2010版
- 怎么呼叫?
- 今天母亲节,祝在远方的母亲健康长寿,也祝天下所有母亲快乐!
- 一个关于路径的问题?
- 怎样在DELPHI写的CGI程序中获得本EXE文件所在目录?
- 在SQL中unicode('我')=25105,那么在Delphi中,如何将25105换算成'我'?
- 请问如何把.db格式的数据导入sybase数据库中呢?
- 有关dbchart的应用,please help me!!!!!
- 许久了,俺一直打算想学一学DELPHI,所以前些天买了N本DELPHI教程,但感觉基础不扎实,学起来有些不顺手。请问各位大哥,有什么介绍QBJECT PASCAL的精典教程吗??
- 500元 请求哪位大侠彻底解决ACTIVEXFORM dax error Access Violation 问题
- 跪求indy http如何向服务器输入用户密码?一直在线等,直到解决,先谢了。
procedure TFrmPrintReport.Button2Click(Sender: TObject);
var
iDomDoc40: DOMDocument40;
iSchemaDoc: DOMDocument40;
iDomParseError: IXMLDOMParseError ;
iSchemaCache: XMLSchemaCache40;
sNameSpace: string;
// iXMLSchema: ISchema;
begin
iSchemaDoc :=CoDOMDocument40.Create;
iSchemaDoc.async := False;
iSchemaDoc.validateOnParse := False;
iSchemaDoc.load(ExtractFilePath(Application.Exename) +'tests\manifest.xsd'); //得到命名空间
sNameSpace := iSchemaDoc.documentElement.getAttributeNode('xmlns:xs').Value; iSchemaCache := CoXMLSchemaCache40.Create;
iSchemaCache.add(sNameSpace, iSchemaDoc);
//iXMLSchema :=iSchemaCache.getSchema(sNameSpace); iDomDoc40 :=CoDOMDocument40.Create;
iDomDoc40.async :=False; //主要是下面这两行代码
iDomDoc40.validateOnParse := True;
iDomDoc40.schemas := iSchemaCache;
iDomDoc40.load('D:\RONGXING\旅客登记II\ReportAir\2007-11-20\SA_0711200845_ZYK.xml');
iDomParseError := iDomDoc40.parseError;
if iDomParseError.errorCode = 0 then
ShowMessage('验证成功'); //如果验证失败,还可以通过下面的信息来定位错误的地方
//iDomParseError.reason;
//iDomParseError.srcText;
//iDomParseError.line;
end;
var
XDoc : IXMLDomDocument2;
XSchemaCache : IXMLDomSchemaCollection2;
errortxt : string;
fs : TfileStream;
data : string;
SchemaFile : WideString;
begin
XDoc := CreateDOMDocument as IXMLDomDocument2; { instancieer SchemaCache }
XSchemaCache := CoXMLSchemaCache40.Create;
try
try
SchemaFile := ExtractFilePath(Application.Exename) +'tests\manifest.xsd';
XSchemaCache.Add('xsi:noNamespaceSchemaLocation', SchemaFile);
except
on E: Exception do
begin
ShowMessageFmt('SchemaCache.add <%s>'#13#10 + 'Error: %s',[SchemaFile, E.Message]);
exit;
end;
end;
try
XDoc.Schemas := XSchemaCache;
XDoc.async := False;
XDoc.resolveExternals := True;
XDoc.validateOnParse := True;
fs := TFileStream.create('D:\RONGXING\旅客登记II\ReportAir\2007-11-20\SA_0711200845_ZYK.xml', fmOpenRead or fmShareDenyWrite);
try
SetLength(data, fs.Size);
fs.Read(data[1], fs.Size);
finally
fs.Free;
end; if not XDoc.loadXML(WideString(data)) then
begin
errortxt := Format('IXMLDomDocument40 error.'#13#10 +
'Reason: %s'#13#10 +
'Source: %s',
[XDoc.parseError.reason, XDoc.parseError.srcText]);
ShowMessage(errortxt);
exit;
end;
except
on E: Exception do
begin
errortxt := Format('IXMLDomDocument40 error: %s'#13#10 +
'Reason: %s'#13#10 +
'Source: %s',
[E.Message, XDoc.parseError.reason, XDoc.parseError.srcText]);
ShowMessage(errortxt);
exit;
end;
end;
finally
ShowMessage('验证成功');
XDoc := nil;
XSchemaCache := nil;
end;
end;
SchemaDoc, XmlDoc: IXMLDOMDocument2;
SchemaCache: IXMLDOMSchemaCollection;
Error: IXMLDOMParseError;
begin
// Load the data
XmlDoc := CoDOMDocument40.Create;
XmlDoc.async := False;
XmlDoc.load('D:\SA_0711200845_ZYK.xml');
// Load the schema doc
SchemaDoc := CoDOMDocument40.Create;
SchemaDoc.async := False;
SchemaDoc.load(ExtractFilePath(Application.Exename) +'tests\manifest.xsd');
// Register the schema with the cache
SchemaCache := CoXMLSchemaCache40.Create;
SchemaCache.add('', schemadoc);
// Assign the schema cache to the document
XmlDoc.schemas := schemacache;
// Validate and report
Error := xmldoc.validate;
if Error.errorCode <> S_OK then
Memo1.Lines.Add(Error.reason)
else
Memo1.Lines.Add('验证成功');
end;