H. Senkaya
H. Senkaya

Reputation: 773

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

I Need to avoid mixed="true" because my Microsoft SSIS grouses if I use mixed="true" in my *.XSD-File. I get the following error message:

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

My XML-File:

  <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>

My XSD-File:

<!-- <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>

This Part: xs:complexType name="ConditionType" mixed="true" is needed because else I get any error message like:

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

What now? I can't use mixed="true" because MS SSIS don't likes it but otherwise I get an error. Can you help me please?

Thanks a lot!

Upvotes: 1

Views: 1757

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167696

If the element respectively type should have no child elements but at least one attribute then you should define it as

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

Upvotes: 1

Related Questions