任何拥有描述 Delphi TClientDataSet XML 文件的 METADATA 部分的部分 XSD 的人? [英] Anyone that has a partial XSD that describes the METADATA section of Delphi TClientDataSet XML files?
问题描述
我知道您无法完全描述带有 XSD 架构的 TClientDataSet 的 XML,因为 ROW 元素的属性名称随内容而异.
I know that you cannot fully describe the XML that the TClientDataSet with an XSD schema, as the ROW elements have attributes that have names that vary with the contents.
但是,这种 XML 的 METADATA 部分应该是.
However, the METADATA section of such an XML should be.
那么:有没有人有一个(部分)XSD,它描述了可以用 Delphi TClientDataSets 保存的 XML 的元数据部分?
So: is there anyone having a (partial) XSD that describes the METADATA portion of the XML that can be saved with Delphi TClientDataSets?
问候.
PS:
感谢指向 XML->XSD 转换工具/站点的指针;我应该写我自己也是这样做的,但是以正确的方式(即涵盖所有可能性的方式)生成 XSD 将需要涵盖所有可能性(如往返、行状态等)的输入 XML.我会尝试以这种方式提出一个像样的 XSD 并将其发布在此处.
Thanks for the pointers to XML->XSD conversion tools/sites; I should have written that I did that myself as well, but that generating that XSD in a proper way (i.e. one that covers all possibilities) will need input XML that cover all possibilities (like roundtrip, rowstate, etc). I'll try to come up with a decent XSD that way and post it here.
推荐答案
将 XSD 拆分为两部分,并通过在 Delphi XE
中使用以下文件使其更加完整:dsconst.h
、dspickle.h
、<代码>dsxml.h.
如有补充请PM或评论.
Split the XSD in two parts, and made it more complete by using these files in Delphi XE
: dsconst.h
, dspickle.h
, dsxml.h
.
Please PM or comment if you have additions.
到目前为止,下面的 XSD 文件似乎工作正常;如果您的 TClientDataSet XML 无法通过此验证,请将您的 XML 电子邮件发送给我(谷歌我或在下面评论我的邮件地址).
The XSD files below seems to work reasonably so far; if you have TClientDataSet XML that does not validate with this, please email me your XML (Google me or put a comment below for my mail address).
首先是文件 CDS.xsd
,其中包括文件 CDS_METADATA_FIELDS_include.xsd
.
它定义了 TClientDataSet XML 文档的基本结构:DATAPACKET
,包含 METADATA
和 ROWDATA
,其中 METADATA
包含 FIELDS
和 PARAMS
,ROWDATA
包含 ROW
元素:
First the file CDS.xsd
, which includes the file CDS_METADATA_FIELDS_include.xsd
further on.
It defines the basic structure of a TClientDataSet XML document: DATAPACKET
, containing METADATA
and ROWDATA
, where METADATA
contains FIELDS
and PARAMS
, and ROWDATA
contains ROW
elements:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="CDS_METADATA_FIELDS_include.xsd"/>
<!-- DATAPACKET/datapacket -->
<xs:element name="DATAPACKET" type="datapacket"/>
<xs:complexType name="datapacket">
<xs:sequence>
<xs:element ref="METADATA"/>
<xs:element ref="ROWDATA"/>
</xs:sequence>
<xs:attribute name="Version" type="xs:NMTOKEN" use="required"/>
</xs:complexType>
<!-- METADATA/metadata -->
<xs:element name="METADATA" type="metadata"/>
<xs:complexType name="metadata">
<xs:sequence>
<xs:element ref="FIELDS"/>
<xs:element ref="PARAMS"/>
</xs:sequence>
</xs:complexType>
<!-- PARAMS/params -->
<xs:element name="PARAMS" type="params"/>
<xs:complexType name="params">
<xs:attribute name="MD_FIELDLINKS" type="xs:string" use="optional"/>
<xs:attribute name="DEFAULT_ORDER" type="xs:positiveInteger"/>
<xs:attribute name="LCID" type="xs:positiveInteger"/>
<xs:attribute name="CHANGE_LOG" type="xs:string" use="optional"/>
<xs:attribute name="PRIMARY_KEY" type="xs:positiveInteger" use="optional"/>
</xs:complexType>
<!-- ROWDATA/rowdata -->
<xs:element name="ROWDATA" type="rowdata"/>
<xs:complexType name="rowdata">
<xs:sequence>
<xs:element ref="ROW" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<!-- ROW/row -->
<xs:element name="ROW" type="row"/>
<xs:complexType name="row">
<xs:sequence>
<xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="RowState" type="xs:NMTOKEN" use="optional"/>
<xs:anyAttribute namespace="##any" processContents="lax"/>
</xs:complexType>
</xs:schema>
请注意,ROW
元素的类型非常松散,因为它们将包含动态定义的属性名称.
Note that ROW
elements are very loosely typed, as they will contain attribute names that are dynamically defined.
然后是 CDS_METADATA_FIELDS_include.xsd
文件,其中包含 FIELDS
和 PARAMS
元素使用的基础元数据.
它还没有完全完成,因为我还没有找到包含下面评论中提到的关键字的 CDS XML 文件.
Then the file CDS_METADATA_FIELDS_include.xsd
which contains the underlying meta data used by the FIELDS
and PARAMS
elements.
It is not yet fully complete, as I haven't found CDS XML files containing the keywords mentioned in the comments below.
<?xml version="1.0" encoding="UTF-8"?>
<!-- include portion of the METADATA FIELDS that CDS uses -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- FIELDS/fields -->
<xs:element name="FIELDS" type="fields"/>
<xs:complexType name="fields">
<xs:sequence>
<xs:element ref="FIELD" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<!-- FIELD/field -->
<xs:element name="FIELD" type="field"/>
<xs:complexType name="field">
<xs:sequence>
<xs:element ref="PARAM" minOccurs="0"/>
<!-- FIELDS is for nested datasets -->
<xs:element ref="FIELDS" minOccurs="0" maxOccurs="unbounded"/>
<!-- PARAMS is for nested datasets -->
<xs:element name="PARAMS" type="fieldParams" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<!-- fieldname is used when the DBMS allows for non-identifier characters (like spaces) in fieldnames -->
<xs:attribute name="fieldname" use="optional" type="xs:string"/>
<xs:attribute name="fieldtype" use="required" type="FIELDTYPE"/>
<xs:attribute name="SUBTYPE" use="optional" type="subtype"/>
<!-- DECIMALS is for BCD -->
<xs:attribute name="DECIMALS" type="xs:positiveInteger" use="optional"/>
<!-- WIDTH is for Character, BCD, Bytes and Unicode -->
<xs:attribute name="WIDTH" type="xs:positiveInteger" use="optional"/>
<xs:attribute name="attrname" type="xs:Name" use="required"/>
<!-- need to incorporate these; probably as attributes as FIELD :
#define szUNIQUE_KEY "UNIQUE_KEY"
#define szSERVER_COL "SERVER_COL"
#define szCONSTRAINTS "CONSTRAINTS"
#define szDATASET_CONTEXT "DATASET_CONTEXT"
#define szDATASET_DELTA "DATASET_DELTA"
#define szREADONLY "READONLY"
#define szBDEDOMX "BDEDOMAIN_X"
#define szBDERECX "BDERECORD_X"
#define szBDEDEFX "BDEDEFAULT_X"
#define szAUTOINCVALUE "AUTOINCVALUE"
#define szELEMENTS "ELEMENTS"
#define szTABLENAME "TABLENAME"
#define szTYPENAME "TYPENAME"
#define szUPDATEMODE "UPDATEMODE"
#define szMD_SEMANTICS "MD_SEMANTICS"
#define szCALCULATED "CALCULATED"
#define szFIELDNAME "FIELDNAME"
-->
</xs:complexType>
<!-- fieldParams -->
<xs:complexType name="fieldParams">
<xs:attribute name="DEFAULT_ORDER" type="xs:positiveInteger"/>
<xs:attribute name="PRIMARY_KEY" type="xs:positiveInteger"/>
<xs:attribute name="LCID" type="xs:positiveInteger"/>
</xs:complexType>
<!-- FIELDTYPE -->
<xs:simpleType name="FIELDTYPE">
<xs:restriction base="xs:Name">
<!-- observed in real life CDS XML: -->
<xs:enumeration value="byte"/>
<!-- from Delphi XE file dsxml.h: -->
<xs:enumeration value="i1"/>
<xs:enumeration value="i2"/>
<xs:enumeration value="i4"/>
<xs:enumeration value="i8"/>
<xs:enumeration value="ui1"/>
<xs:enumeration value="ui2"/>
<xs:enumeration value="ui4"/>
<xs:enumeration value="ui8"/>
<xs:enumeration value="r4"/>
<xs:enumeration value="r8"/>
<xs:enumeration value="r10"/>
<!-- szXMLFloat/szXMLNumber <xs:enumeration value="r8"/> -->
<xs:enumeration value="fixed"/>
<xs:enumeration value="fixedFMT"/>
<xs:enumeration value="boolean"/>
<xs:enumeration value="date"/>
<xs:enumeration value="dateTime"/>
<xs:enumeration value="time"/>
<xs:enumeration value="array"/>
<xs:enumeration value="struct"/>
<xs:enumeration value="nested"/>
<xs:enumeration value="string.uni"/>
<xs:enumeration value="string"/>
<xs:enumeration value="bin.hex"/>
<xs:enumeration value="IntArray"/>
<xs:enumeration value="UIntArray"/>
<xs:enumeration value="SQLdateTime"/>
<xs:enumeration value="SQLdateTimeOffset"/>
</xs:restriction>
</xs:simpleType>
<!-- subtype -->
<xs:simpleType name="subtype">
<xs:restriction base="xs:Name">
<xs:enumeration value="Text"/>
<xs:enumeration value="Binary"/>
<xs:enumeration value="Formatted"/>
<xs:enumeration value="Ole"/>
<xs:enumeration value="Graphics"/>
<xs:enumeration value="dBASEOle"/>
<xs:enumeration value="TypedBinary"/>
<xs:enumeration value="Money"/>
<xs:enumeration value="Autoinc"/>
<xs:enumeration value="AccessOle"/>
<xs:enumeration value="HMemo"/>
<xs:enumeration value="HBinary"/>
<xs:enumeration value="ADTNestedTable"/>
<xs:enumeration value="FixedChar"/>
<xs:enumeration value="Reference"/>
<xs:enumeration value="BFile"/>
<xs:enumeration value="ADTDate"/>
<xs:enumeration value="Guid"/>
<xs:enumeration value="WideText"/>
<!-- Binary is required for fieldtype="bin.hex" -->
<!-- FixedChar is required for fieldtype="string" when the field is CHAR (but not NCHAR) -->
<!-- Guid is required for fieldtype="string" when the field is GUID -->
<!-- Text is required for fieldtype="bin.hex" when the underlying field is TEXT or NTEXT (memo?) -->
<!-- Money is required for fieldtype="float" when the underlying field is CURRENCY -->
</xs:restriction>
</xs:simpleType>
<!-- PARAM/param -->
<xs:element name="PARAM" type="param"/>
<xs:complexType name="param">
<xs:attribute name="Name" type="paramName" use="required"/>
<!-- two forms of Value are possible; xs:Name is for ORIGIN; xs:postiveInteger is for PROVFLAGS (in combination with Type)
<xs:attribute name="Value" type="xs:Name" use="required"/>
<xs:attribute name="Value" type="xs:postiveInteger" use="required"/>
-->
<xs:attribute name="Value" type="xs:string" use="required"/>
<xs:attribute name="Type" type="FIELDTYPE" use="optional"/>
<xs:attribute name="Roundtrip" type="xs:Name" use="required" fixed="True"/>
</xs:complexType>
<!-- paramName -->
<xs:simpleType name="paramName">
<xs:restriction base="xs:Name">
<xs:enumeration value="ORIGIN"/>
<xs:enumeration value="PROVFLAGS"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
问候.
这篇关于任何拥有描述 Delphi TClientDataSet XML 文件的 METADATA 部分的部分 XSD 的人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!