xsd - 如何避免 mixed="true" 有什么选择?

xsd - How to avoid mixed="true" what is the alternative?

我需要避免使用 mixed="true",因为如果我在 *.XSD-File 中使用 mixed="true",我的 Microsoft SSIS 就会抱怨。我收到以下错误消息:

"...The XML source adapter does not support the model of mixed content on complex types"

我的XML-文件:

  <MappingProject name="anyString1">
     <MappingSpecification name="anyString2">
        <MappingTargetTable>TEXT_BLOCK1</MappingTargetTable>
        <MappingSourceTables>
           <Table>TEXT_BLOCK2</Table>
           <Table>TEXT_BLOCK3</Table>
        </MappingSourceTables>
        <Description>
           <DescriptionText>Some Text...  </DescriptionText>
           <Condition type="filter"> -</Condition>
        </Description>
     </MappingSpecification>
  </MappingProject>

我的XSD-文件:

<!-- <MappingProject> -->
<xs:element name="MappingProject">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="MappingSpecification" type="MappingSpecificationType"/>
        </xs:sequence>
    <xs:attribute name="name" type="xs:string" use="required"/>
    </xs:complexType>
</xs:element>

<!-- MappingSpecification -->
<xs:complexType name="MappingSpecificationType">
    <xs:sequence>
        <xs:element name="MappingTargetTable" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element name="MappingSourceTables" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element name="Description" type="DescriptionType" minOccurs="1"/>
    </xs:sequence>
    <xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>

<!-- Description -->
<xs:complexType name="DescriptionType">
    <xs:sequence>
        <xs:element name="DescriptionText"/>
        <xs:element name="Condition" type="ConditionType"/>
    </xs:sequence>
</xs:complexType>

<!-- Condition-->
<xs:complexType name="ConditionType" mixed="true">
    <xs:attribute name="type" type="xs:string" use="required"/>
</xs:complexType>

这部分:xs:complexType name="ConditionType" mixed="true" 是必需的,否则我会收到任何错误消息,例如:

"Element 'Condition' cannot have character [children], because the type's content type is element-only."

现在怎么办?我不能使用 mixed="true" 因为 MS SSIS 不喜欢它,否则我会收到错误消息。你能帮帮我吗?

非常感谢!

如果元素分别类型应该没有子元素但至少有一个属性,那么您应该将其定义为

<xs:complexType name="ConditionType">
          <xs:simpleContent>
            <xs:extension base="string">
              <xs:attribute name="type" type="xs:string" use="required"/>
            </extension>
          </xs:simpleContent>
</xs:complexType>