none
Help with manual schema for Service RRS feed

  • Question

  • I am new to generating schemas in the way I am doing it now (Manually) and sort of need some help here please. I have a schema, as below, that I am not sure is even correct. What I want is a Customer record that can contain more than one Address record. What I have below does not seem correct, or is it? I am referring in particular to where I have the MAXOCCURS=UNBOUNDED applied. How do you think I ought to do this instead? Thanks in advance


     <xs:element name="Customer">
      <xs:complexType>
      <xs:sequence>
      <xs:element name="CustomerCode" type="xs:string" />
      <xs:element name="Name" type="xs:string" />
      <xs:element name="Active" type="xs:int" />
      <xs:element name="SubNumber" type="xs:string" />
      <xs:element name="CustomerAccountNumber" type="xs:string" />
      <xs:element name="AccountBranchCode" type="xs:string" />
      <xs:element name="BranchLocationCode" type="xs:string" />
      <xs:element name="Attention" type="xs:string" />
      <xs:element maxOccurs="unbounded" name="Addresses">
      <xs:complexType>
      <xs:sequence>
      <xs:element name="Street1" type="xs:string" />
      <xs:element name="Street2" type="xs:string" />
      <xs:element name="City" type="xs:string" />
      <xs:element name="State" type="xs:string" />
      <xs:element name="Zip" type="xs:string" />
      <xs:element name="Country" type="xs:string" />
      <xs:element name="Description" type="xs:string" />
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      <xs:element maxOccurs="unbounded" name="PhoneNumbers">
      <xs:complexType>
      <xs:sequence>
      <xs:element name="PhoneNumber" type="xs:string" />
      <xs:element name="PhoneType" type="xs:string" />
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:sequence>
      </xs:complexType>
      </xs:element>
    Sunday, February 14, 2010 5:44 AM

Answers

  • Hi,

    Your schema looks like this (similar to yours):

    <?xml version="1.0" encoding="utf-16"?>
    <xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://HRMApplication.Schemas.Customer" targetNamespace="http://HRMApplication.Schemas.Customer" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="Customer">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="CustomerCode" type="xs:string" />
            <xs:element name="Name" type="xs:string" />
            <xs:element name="Active" type="xs:int" />
            <xs:element name="SubNumber" type="xs:string" />
            <xs:element name="CustomerAccountNumber" type="xs:string" />
            <xs:element name="AccountBranchCode" type="xs:string" />
            <xs:element name="BranchLocationCode" type="xs:string" />
            <xs:element name="Attention" type="xs:string" />
            <xs:element minOccurs="0" maxOccurs="unbounded" name="Addresses">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="Street1" type="xs:string" />
                  <xs:element name="Street2" type="xs:string" />
                  <xs:element name="City" type="xs:string" />
                  <xs:element name="State" type="xs:string" />
                  <xs:element name="Zip" type="xs:string" />
                  <xs:element name="Country" type="xs:string" />
                  <xs:element name="Description" type="xs:string" />
                </xs:sequence>
              </xs:complexType>
            </xs:element>
            <xs:element minOccurs="0" maxOccurs="unbounded" name="PhoneNumbers">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="PhoneNumber" type="xs:string" />
                  <xs:element name="PhoneType" type="xs:string" />
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>

    And if you right click this schema in Visual Studio and click Generate instance than this will be the result:

    <ns0:Customer xmlns:ns0="http://YourName.Schemas.Customer">
      <CustomerCode>CustomerCode_0</CustomerCode>
      <Name>Name_0</Name>
      <Active>10</Active>
      <SubNumber>SubNumber_0</SubNumber>
      <CustomerAccountNumber>CustomerAccountNumber_0</CustomerAccountNumber>
      <AccountBranchCode>AccountBranchCode_0</AccountBranchCode>
      <BranchLocationCode>BranchLocationCode_0</BranchLocationCode>
      <Attention>Attention_0</Attention>
    <Addresses>
      <Street1>Street1_0</Street1>
      <Street2>Street2_0</Street2>
      <City>City_0</City>
      <State>State_0</State>
      <Zip>Zip_0</Zip>
      <Country>Country_0</Country>
      <Description>Description_0</Description>
      </Addresses>
    <Addresses>
      <Street1>Street1_0</Street1>
      <Street2>Street2_0</Street2>
      <City>City_0</City>
      <State>State_0</State>
      <Zip>Zip_0</Zip>
      <Country>Country_0</Country>
      <Description>Description_0</Description>
      </Addresses>
    <Addresses>
      <Street1>Street1_0</Street1>
      <Street2>Street2_0</Street2>
      <City>City_0</City>
      <State>State_0</State>
      <Zip>Zip_0</Zip>
      <Country>Country_0</Country>
      <Description>Description_0</Description>
      </Addresses>
    <PhoneNumbers>
      <PhoneNumber>PhoneNumber_0</PhoneNumber>
      <PhoneType>PhoneType_0</PhoneType>
      </PhoneNumbers>
    <PhoneNumbers>
      <PhoneNumber>PhoneNumber_0</PhoneNumber>
      <PhoneType>PhoneType_0</PhoneType>
      </PhoneNumbers>
    <PhoneNumbers>
      <PhoneNumber>PhoneNumber_0</PhoneNumber>
      <PhoneType>PhoneType_0</PhoneType>
      </PhoneNumbers>
    </ns0:Customer>

    As you can see a customer can have more addresses and phonenumbers and this what you wanted. More on schema generation and validation can be found here: http://msdn.microsoft.com/en-us/library/aa560938(BTS.10).aspx.

    Regards,

    Steef-Jan Wiggers
    MCTS BizTalk Server
    http://soa-thoughts.blogspot.com/
    If this answers your question please mark it accordingly


    BizTalk Server
    Sunday, February 14, 2010 10:08 AM
    Moderator