我需要找到使用拓扑表示定义线的方法。现在我有了类似的内容:
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<Points>
<Point>
<UIDP>1</UIDP>
<X>5379847.689</X>
<Y>1223602.644</Y>
<MX>0.05</MX>
<MY>0.05</MY>
</Point>
<Point>
<UIDP>2</UIDP>
<X>5379828.473</X>
<Y>1223606.113</Y>
<MX>0.05</MX>
<MY>0.05</MY>
</Point>
</Points>
<Lines>
<Line>
<Point>1</Point>/>
<Point>2</Point>/>
</Line>
</Lines>
</Root>
其中Line/Point为点唯一id(UIDP)的值。
- 有没有办法让它更清楚,不仅得到ID而且得到洞点定义使用引用或类似的东西?
- 如何使用XLink或XPointer? 如何在XSD Schema 1.1中定义它?
我没有找到如何通过XLink或XPointer制作它,但了解如何通过XSD定义部分规则。
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" vc:minVersion="1.1">
<xsd:complexType name="point">
<xsd:sequence>
<xsd:element name="UIDP" type="xsd:integer"/>
<xsd:element name="X" type="xsd:float"/>
<xsd:element name="Y" type="xsd:float"/>
<xsd:element name="MX" type="xsd:float"/>
<xsd:element name="MY" type="xsd:float"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="line">
<xsd:sequence>
<xsd:element name="Point1" type="xsd:integer"/>
<xsd:element name="Point2" type="xsd:integer"/>
</xsd:sequence>
<xsd:assert test="Point1 != Point2"/>
</xsd:complexType>
<xsd:element name="Root">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Points">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Point" type="point" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Lines">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Line" type="line" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:unique name="lines_unique">
<xsd:selector xpath="Line"/>
<xsd:field xpath="Point1"/>
<xsd:field xpath="Point2"/>
</xsd:unique>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:key name="point_uidp">
<xsd:selector xpath="Points/Point"></xsd:selector>
<xsd:field xpath="UIDP"></xsd:field>
</xsd:key>
<xsd:keyref refer="point_uidp" name="point_1">
<xsd:selector xpath="Lines/Line/Point1"></xsd:selector>
<xsd:field xpath="."></xsd:field>
</xsd:keyref>
<xsd:keyref refer="point_uidp" name="point_2">
<xsd:selector xpath="Lines/Line/Point2"></xsd:selector>
<xsd:field xpath="."></xsd:field>
</xsd:keyref>
</xsd:element>
</xsd:schema>
schema定义的规则:
- 所有的点id必须是唯一的,必须出现,不能为NULL
- 所有的线点链接必须来自点id的范围
- 行点链接必须是唯一的,不能在其他行 中复制。
。. NET DataSet
类自动生成以下模式(为了清晰起见,我添加了空行):
<?xml version="1.0" standalone="yes"?>
<Root>
<xs:schema id="Root" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Root" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Point">
<xs:complexType>
<xs:sequence>
<xs:element name="UIDP" type="xs:int" />
<xs:element name="X" type="xs:double" minOccurs="0" />
<xs:element name="Y" type="xs:double" minOccurs="0" />
<xs:element name="MX" type="xs:double" minOccurs="0" />
<xs:element name="MY" type="xs:double" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Line">
<xs:complexType>
<xs:sequence>
<xs:element name="Point1" type="xs:int" />
<xs:element name="Point2" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="PK_Points" msdata:PrimaryKey="true">
<xs:selector xpath=".//Point" />
<xs:field xpath="UIDP" />
</xs:unique>
<xs:unique name="PK_Lines" msdata:PrimaryKey="true">
<xs:selector xpath=".//Line" />
<xs:field xpath="Point1" />
<xs:field xpath="Point2" />
</xs:unique>
<xs:keyref name="FK_Lines2" refer="PK_Points" msdata:ConstraintOnly="true">
<xs:selector xpath=".//Line" />
<xs:field xpath="Point2" />
</xs:keyref>
<xs:keyref name="FK_Lines1" refer="PK_Points" msdata:ConstraintOnly="true">
<xs:selector xpath=".//Line" />
<xs:field xpath="Point1" />
</xs:keyref>
</xs:element>
</xs:schema>
<Point>
<UIDP>1</UIDP>
<X>5379847.689</X>
<Y>1223602.644</Y>
<MX>0.05</MX>
<MY>0.05</MY>
</Point>
<Point>
<UIDP>2</UIDP>
<X>5379828.473</X>
<Y>1223606.113</Y>
<MX>0.05</MX>
<MY>0.05</MY>
</Point>
<Line>
<Point1>1</Point1>
<Point2>2</Point2>
</Line>
</Root>
方案与数据一起在单个文件中生成。
注意Points
和Lines
元素的缺失。
是1.0版本的模式。因此,更高级的检查是不可用的。
可以删除msdata
前缀的属性