我正在尝试构建一个元素类型,它保留了一个change
元素类型的列表,该元素类型是几个其他子类型的基本类型。我得到了这段代码:
<xs:complexType name="change_list" >
<xs:annotation>
<xs:documentation>List of changes.</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:choice minOccurs="1" maxOccurs="unbounded" >
<xs:element name="change" type="aos:change" >
<xs:annotation>
<xs:documentation>Generic or specific type of change.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="activate" type="aos:activate" >
<xs:annotation>
<xs:documentation>Change that will activate an element or do nothing if already activated.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="deactivate" type="aos:deactivate" >
<xs:annotation>
<xs:documentation>Change that will deactivate an element or do nothing if already deactivated.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="switch" type="aos:switch" >
<xs:annotation>
<xs:documentation>Change that will activate the element if deactivated or deactivate it if activated.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="transform" type="aos:transform" >
<xs:annotation>
<xs:documentation>
Change that will modify the geometric state of the element
by applying one or several geometric transformations.
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
</xs:sequence>
我正在使用CodeSynthesis生成C++代码。
现在,这似乎过于复杂了,因为我们已经清楚地定义了对不同类型的访问。我认为我想要的是更简单的东西,比如:
更改列表。
<xs:sequence>
<xs:choice minOccurs="1" maxOccurs="unbounded" >
<xs:element name="change" type="aos:change" >
<xs:annotation>
<xs:documentation>Generic or specific type of change.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
</xs:sequence>
现在我不能为不同的更改子类型使用不同的标签。 所以我想也许一个好的解决方案是使用替换组。 但那样我就失去了使用特定子类型属性和元素的能力。 原始解决方案是否适合这样做(拥有一个可以获取子类型的基础类型对象列表)?