Search code examples
xsdbiztalkbiztalk-schemas

Is there a way to handle/ignore inline xsd in received xml file in biztalk?


Client sends a file containing customer data in xml. The problem is that it also contains the xsd they use. Is there a way when setting up the source schema in biztalk to make it validate while ignoring the xsd?

I've tried including nodes for it, but it does not validate due to some namespace error, and it keeps looking for the first element node containing customer data

<Root>
  <xsd:schema id="Root" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:element name="Root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="Data" minOccurs="0" maxOccurs="unbounded">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="number" type="xsd:int"/>
                <xsd:element name="name">
                    <xsd:simpleType>
                      <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="60"/>
                      </xsd:restriction>
                    </xsd:simpleType>
                </xsd:element>
                <xsd:element name="address">
                  <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                      <xsd:maxLength value="30"/>
                    </xsd:restriction>
                  </xsd:simpleType>
                </xsd:element>
                <xsd:element name="Zip">
                  <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                      <xsd:maxLength value="5"/>
                    </xsd:restriction>
                  </xsd:simpleType>
                </xsd:element>
                <xsd:element name="telephone">
                  <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                      <xsd:maxLength value="60"/>
                    </xsd:restriction>
                  </xsd:simpleType>
                </xsd:element>
                <xsd:element name="custNumber">
                  <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                      <xsd:maxLength value="11"/>
                    </xsd:restriction>
                  </xsd:simpleType>
                </xsd:element>
                <xsd:element name="branchnumber" type="xsd:int"/>
                </xsd:element>
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
        <xsd:anyAttribute namespace="http://www.w3.org/XML/1998/namespace" processContents="lax"/>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>

    <Data>
        <number>12345</number>
        <name>Scrooge McDuck</name>
        <address>Address 1</adresse>
        <Zip>0000</Zip>
        <telephone>1234563290</telephone>
        <custNumber>123324</custNumber>
        <branchnumber>0</branchnumber>
    </Data>
    <Data>
        <number>23456</number>
        <name>Donald Duck</name>
        <address>Address 4</adresse>
        <Zip>4625</Zip>
        <telephone>1234567890</telephone>
        <custNumber>123321</custNumber>
        <branchnumber>0</branchnumber>
    </Data>
</Root>

Solution

  • I don't think this would actually cause a problem.

    First, don't bother validating at runtime, no one ever does this and it's never mattered.

    The schema should only contain the content nodes, this will work just fine in the Mapper, Properties etc.

    Since you're not validating, provided the Schema is valid xml, it'll just go along for the ride and will be ignored.

    To Validate in VS, just take the Schema nodes out.