F
fishding
Unregistered / Unconfirmed
GUEST, unregistred user!
以下是我的程序代码:
*******************************************************
procedure TForm1.Button5Click(Sender: TObject);
var
xmlobj:TDOMDocument40;
xmlsch:TXMLSchemaCache40;
namespace,xsdname,xmlname:string;
begin
namespace:='urn:records';
xsdname:='XLQ.xsd';
xmlname:='XLQ.xml';
xmlobj := TDOMDocument40.Create(nil);
xmlsch := TXMLSchemaCache40.Create(nil);
xmlsch.DefaultInterface.add(namespace,xsdname);
xmlobj.DefaultInterface.schemas := xmlsch.DefaultInterface;
xmlobj.DefaultInterface.async := False;
xmlobj.DefaultInterface.validateOnParse := True;
xmlobj.DefaultInterface.resolveExternals:=True;
xmlobj.DefaultInterface.load(xmlname);
if xmlobj.DefaultInterface.parseError.errorCode = 0 then
showmessage('格式正确')
else
begin
showmessage('格式错误');
showmessage(xmlobj.DefaultInterface.parseError.reason
+xmlobj.DefaultInterface.parseError.srcText
+' line:'+IntToStr(xmlobj.DefaultInterface.parseError.line)
+' char:'+IntToStr(xmlobj.DefaultInterface.parseError.linepos));
end;
end;
*******************************************************
我在程序运行后出现以下错误:
“sstzclass”/union/ undeclared XSD type:'noneclass'
*******************************************************
我分析是我定义的xsd文件中的联合类型出现问题,但是我仔细检查我的xsd文件,对照
MSXML4.0的文档,我始终无法找到问题所在.请各位高手多多指点。如果可能的话,给我一个使用了union类型定义的xsd文件的示例。谢谢。
我的xsd的内容是:
******************************************************
<?xml version="1.0"
encoding="GB2312"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="records"
type="recordlist"/>
<!-- Defines the complex type for the "recording"
element.-->
<xsd:complexType name="onerecord">
<xsd:attribute name="zymc"
type="string1to20"
use="required"/>
<xsd:attribute name="flbsm"
type="long10"
use="required"/>
<xsd:attribute name="ssbddw"
type="long15"
use="required"/>
<xsd:attribute name="sstz"
type="sstzclass"
use="required"/>
<xsd:attribute name="sswx"
type="sswxclass"
use="required"/>
<xsd:attribute name="zybh"
type="long1to15"
use="required"/>
<xsd:attribute name="xlqlx"
type="xlqclass"
use="required"/>
<xsd:attribute name="xlqbh"
type="long1to15"
use="required"/>
</xsd:complexType>
<!-- Defines the root element for the XML file.-->
<xsd:complexType name="recordlist">
<xsd:sequence>
<xsd:element name="record"
type="onerecord"
minOccurs="1"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!--定义所属台站类型-->
<xsd:simpleType name="sstzclass">
<xsd:union memberTypes="noneclass long15"/>
</xsd:simpleType>
<!--定义所属网系类型-->
<xsd:simpleType name="sswxclass">
<xsd:union memberTypes="noneclass long1to10"/>
</xsd:simpleType>
<!--定义信令区类型-->
<xsd:simpleType name="xlqclass">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="主信令区"/>
<xsd:enumeration value="分信令区"/>
</xsd:restriction>
</xsd:simpleType>
<!--定义长度小于20的字符串类型-->
<xsd:simpleType name="string1to20">
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="20"/>
</xsd:restriction>
</xsd:simpleType>
<!--定义长度为10的整数类型-->
<xsd:simpleType name="long10">
<xsd:restriction base="xsd:unsigneLong">
<xsd:minInclusive value="1000000000"/>
<xsd:maxInclusive value="9999999999"/>
</xsd:restriction>
</xsd:simpleType>
<!--定义长度为15的整数类型-->
<xsd:simpleType name="long15">
<xsd:restriction base="xsd:unsigneLong">
<xsd:minInclusive value="100000000000000"/>
<xsd:maxInclusive value="999999999999999"/>
</xsd:restriction>
</xsd:simpleType>
<!--定义长度小于10的整数类型-->
<xsd:simpleType name="long1to10">
<xsd:restriction base="xsd:unsigneLong">
<xsd:minInclusive value="1"/>
<xsd:maxInclusive value="9999999999"/>
</xsd:restriction>
</xsd:simpleType>
<!--定义长度小于15的整数类型-->
<xsd:simpleType name="long1to15">
<xsd:restriction base="xsd:unsigneLong">
<xsd:minInclusive value="1"/>
<xsd:maxInclusive value="999999999999999"/>
</xsd:restriction>
</xsd:simpleType>
<!--定义none类型-->
<xsd:simpleType name="noneclass">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="none"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
************************************************************
*******************************************************
procedure TForm1.Button5Click(Sender: TObject);
var
xmlobj:TDOMDocument40;
xmlsch:TXMLSchemaCache40;
namespace,xsdname,xmlname:string;
begin
namespace:='urn:records';
xsdname:='XLQ.xsd';
xmlname:='XLQ.xml';
xmlobj := TDOMDocument40.Create(nil);
xmlsch := TXMLSchemaCache40.Create(nil);
xmlsch.DefaultInterface.add(namespace,xsdname);
xmlobj.DefaultInterface.schemas := xmlsch.DefaultInterface;
xmlobj.DefaultInterface.async := False;
xmlobj.DefaultInterface.validateOnParse := True;
xmlobj.DefaultInterface.resolveExternals:=True;
xmlobj.DefaultInterface.load(xmlname);
if xmlobj.DefaultInterface.parseError.errorCode = 0 then
showmessage('格式正确')
else
begin
showmessage('格式错误');
showmessage(xmlobj.DefaultInterface.parseError.reason
+xmlobj.DefaultInterface.parseError.srcText
+' line:'+IntToStr(xmlobj.DefaultInterface.parseError.line)
+' char:'+IntToStr(xmlobj.DefaultInterface.parseError.linepos));
end;
end;
*******************************************************
我在程序运行后出现以下错误:
“sstzclass”/union/ undeclared XSD type:'noneclass'
*******************************************************
我分析是我定义的xsd文件中的联合类型出现问题,但是我仔细检查我的xsd文件,对照
MSXML4.0的文档,我始终无法找到问题所在.请各位高手多多指点。如果可能的话,给我一个使用了union类型定义的xsd文件的示例。谢谢。
我的xsd的内容是:
******************************************************
<?xml version="1.0"
encoding="GB2312"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="records"
type="recordlist"/>
<!-- Defines the complex type for the "recording"
element.-->
<xsd:complexType name="onerecord">
<xsd:attribute name="zymc"
type="string1to20"
use="required"/>
<xsd:attribute name="flbsm"
type="long10"
use="required"/>
<xsd:attribute name="ssbddw"
type="long15"
use="required"/>
<xsd:attribute name="sstz"
type="sstzclass"
use="required"/>
<xsd:attribute name="sswx"
type="sswxclass"
use="required"/>
<xsd:attribute name="zybh"
type="long1to15"
use="required"/>
<xsd:attribute name="xlqlx"
type="xlqclass"
use="required"/>
<xsd:attribute name="xlqbh"
type="long1to15"
use="required"/>
</xsd:complexType>
<!-- Defines the root element for the XML file.-->
<xsd:complexType name="recordlist">
<xsd:sequence>
<xsd:element name="record"
type="onerecord"
minOccurs="1"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<!--定义所属台站类型-->
<xsd:simpleType name="sstzclass">
<xsd:union memberTypes="noneclass long15"/>
</xsd:simpleType>
<!--定义所属网系类型-->
<xsd:simpleType name="sswxclass">
<xsd:union memberTypes="noneclass long1to10"/>
</xsd:simpleType>
<!--定义信令区类型-->
<xsd:simpleType name="xlqclass">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="主信令区"/>
<xsd:enumeration value="分信令区"/>
</xsd:restriction>
</xsd:simpleType>
<!--定义长度小于20的字符串类型-->
<xsd:simpleType name="string1to20">
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="20"/>
</xsd:restriction>
</xsd:simpleType>
<!--定义长度为10的整数类型-->
<xsd:simpleType name="long10">
<xsd:restriction base="xsd:unsigneLong">
<xsd:minInclusive value="1000000000"/>
<xsd:maxInclusive value="9999999999"/>
</xsd:restriction>
</xsd:simpleType>
<!--定义长度为15的整数类型-->
<xsd:simpleType name="long15">
<xsd:restriction base="xsd:unsigneLong">
<xsd:minInclusive value="100000000000000"/>
<xsd:maxInclusive value="999999999999999"/>
</xsd:restriction>
</xsd:simpleType>
<!--定义长度小于10的整数类型-->
<xsd:simpleType name="long1to10">
<xsd:restriction base="xsd:unsigneLong">
<xsd:minInclusive value="1"/>
<xsd:maxInclusive value="9999999999"/>
</xsd:restriction>
</xsd:simpleType>
<!--定义长度小于15的整数类型-->
<xsd:simpleType name="long1to15">
<xsd:restriction base="xsd:unsigneLong">
<xsd:minInclusive value="1"/>
<xsd:maxInclusive value="999999999999999"/>
</xsd:restriction>
</xsd:simpleType>
<!--定义none类型-->
<xsd:simpleType name="noneclass">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="none"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
************************************************************