访问contentmodel中的partilces时,我得到的'参数不正确',但可以读取itemtype。有人能告诉我该怎么做吗?提前致谢。如何使用delphi在msxml6中访问complextype中的粒子?
//Book.xsd
<xs:schema xmlns="urn:bookstore-schema" targetNamespace="urn:bookstore-schema"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="book" type="booktype" />
<xs:complexType name="booktype">
<xs:sequence>
<xs:element name="author" type="xs:string" />
<xs:element name="price" type="xs:decimal" />
<xs:element name="aaa" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:element name="another" type="xs:string" />
procedure AccessSchema;
var oSchemaCache : XMLSchemaCache60;
oSchema : ISchema;
nsTarget : string;
kk : integer;
procedure AccessComplexType(oComplex : iSchemaItem);
var ISchComplex : ISchemaComplexType;
begin
ISchComplex := oComplex as ISchemaComplexType;
if (iSchComplex.contentType = SCHEMACONTENTTYPE_MIXED) or
(iSchComplex.contentType = SCHEMACONTENTTYPE_ELEMENTONLY) then
begin
if (iSchComplex.contentModel.ItemType = SOMITEM_CHOICE) or
(iSchComplex.contentModel.ItemType = SOMITEM_SEQUENCE) then
begin
if IschComplex.contentModel.particles.length > 0 then
//error : the parameter is incorrect
begin
{handling particles }
end;
end;
end;
end;
begin
oSchemaCache := coXMLSchemaCache60.Create;
nsTarget := 'urn:bookstore-schema';
oSchemaCache.add(nsTarget,'c:\book.xsd');
oSchema := oSchemaCache.getSchema(nsTarget);
for kk := 0 to pred(oschema.types.length) do
begin
if (oschema.types.item[kk].itemType = SOMITEM_COMPLEXTYPE) then
AccessComplexType(oschema.types.item[kk]);
end;
端;