xml schema design

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy B

    xml schema design

    I have an xml schema that I am working on. I wanted to know if it was a
    normal thing to do something like this:

    1. Have a ZipCode simple type that has to be 5 characters long.
    2. Have a StateCode simple type that has to be 2 characters long.
    3. Have an Address complex type that has:
    - Street (string)
    - City (sgring)
    - State (StateCode) [noted in item 2 above]
    - ZipCode (ZipCode) [noted in item 1 above]
    4. Have a Venue complex type that has the following:
    - Name (string)
    - Address (Address) [noted in item 3 above]
    - PhoneNumber (string)
    5. Have an element that can contain only 1 instance of the Venue complex
    type.



  • Martin Honnen

    #2
    Re: xml schema design

    Andy B wrote:
    I have an xml schema that I am working on. I wanted to know if it was a
    normal thing to do something like this:
    >
    1. Have a ZipCode simple type that has to be 5 characters long.
    2. Have a StateCode simple type that has to be 2 characters long.
    3. Have an Address complex type that has:
    - Street (string)
    - City (sgring)
    - State (StateCode) [noted in item 2 above]
    - ZipCode (ZipCode) [noted in item 1 above]
    4. Have a Venue complex type that has the following:
    - Name (string)
    - Address (Address) [noted in item 3 above]
    - PhoneNumber (string)
    5. Have an element that can contain only 1 instance of the Venue complex
    type.
    Sounds fine to me, you might additionally restrict zip code to five
    digits, enumerate the possible state codes.

    --

    Martin Honnen --- MVP XML

    Comment

    • Andy B

      #3
      Re: xml schema design

      Sounds fine to me, you might additionally restrict zip code to five
      digits, enumerate the possible state codes.
      I forgot about the fact that I had ZipCode set to require 5 characters. I
      want to make this a 5 digit number but cant find a length property for the
      int or integer data type. How would I fix this? I have it set to ZipCode
      (string) - length=5. You also said to make an enum for the state codes. How
      exactly do I do this?




      Comment

      • Martin Honnen

        #4
        Re: xml schema design

        Andy B wrote:
        >Sounds fine to me, you might additionally restrict zip code to five
        >digits, enumerate the possible state codes.
        >
        I forgot about the fact that I had ZipCode set to require 5 characters. I
        want to make this a 5 digit number but cant find a length property for the
        int or integer data type. How would I fix this? I have it set to ZipCode
        (string) - length=5. You also said to make an enum for the state codes. How
        exactly do I do this?
        Straight from <URL:http://www.w3.org/TR/xmlschema-0/is this example:

        <xsd:simpleTy pe name="USState">
        <xsd:restrictio n base="xsd:strin g">
        <xsd:enumeratio n value="AK"/>
        <xsd:enumeratio n value="AL"/>
        <xsd:enumeratio n value="AR"/>
        <!-- and so on ... -->
        </xsd:restriction >
        </xsd:simpleType>

        As for the zip code, one way is with a regular expression pattern:
        <xsd:simpleTy pe name="zipType">
        <xsd:restrictio n base="xsd:posit iveInteger">
        <xsd:pattern value="\d{5}"/>
        </xsd:restriction >
        </xsl:simpleType>



        --

        Martin Honnen --- MVP XML

        Comment

        • Andy B

          #5
          Re: xml schema design

          Why would it be a good idea to do an enum for the state codes instead of
          just letting somebody typing it in just a string field?
          "Martin Honnen" <mahotrash@yaho o.dewrote in message
          news:%23NC45nBk IHA.1168@TK2MSF TNGP02.phx.gbl. ..
          Andy B wrote:
          >>Sounds fine to me, you might additionally restrict zip code to five
          >>digits, enumerate the possible state codes.
          >>
          >I forgot about the fact that I had ZipCode set to require 5 characters. I
          >want to make this a 5 digit number but cant find a length property for
          >the int or integer data type. How would I fix this? I have it set to
          >ZipCode (string) - length=5. You also said to make an enum for the state
          >codes. How exactly do I do this?
          >
          Straight from <URL:http://www.w3.org/TR/xmlschema-0/is this example:
          >
          <xsd:simpleTy pe name="USState">
          <xsd:restrictio n base="xsd:strin g">
          <xsd:enumeratio n value="AK"/>
          <xsd:enumeratio n value="AL"/>
          <xsd:enumeratio n value="AR"/>
          <!-- and so on ... -->
          </xsd:restriction >
          </xsd:simpleType>
          >
          As for the zip code, one way is with a regular expression pattern:
          <xsd:simpleTy pe name="zipType">
          <xsd:restrictio n base="xsd:posit iveInteger">
          <xsd:pattern value="\d{5}"/>
          </xsd:restriction >
          </xsl:simpleType>
          >
          >
          >
          --
          >
          Martin Honnen --- MVP XML
          http://JavaScript.FAQTs.com/

          Comment

          • Martin Honnen

            #6
            Re: xml schema design

            Andy B wrote:
            Why would it be a good idea to do an enum for the state codes instead of
            just letting somebody typing it in just a string field?
            In terms of the W3C schema language I suggested an _enumeration_ below:
            ><xsd:simpleTyp e name="USState">
            > <xsd:restrictio n base="xsd:strin g">
            > <xsd:enumeratio n value="AK"/>
            > <xsd:enumeratio n value="AL"/>
            > <xsd:enumeratio n value="AR"/>
            > <!-- and so on ... -->
            > </xsd:restriction >
            ></xsd:simpleType>
            Or are you now talking about a .NET enumeration defined with C# or VB.NET?

            --

            Martin Honnen --- MVP XML

            Comment

            • Andy B

              #7
              Re: xml schema design

              You have the right thing. Does it do the same thing a c# enum would do?
              either restrict the strings that can be used, or make useful names for
              meaningless numbers (like a c# enum does)?
              "Martin Honnen" <mahotrash@yaho o.dewrote in message
              news:OmHhkUDkIH A.1184@TK2MSFTN GP04.phx.gbl...
              Andy B wrote:
              >Why would it be a good idea to do an enum for the state codes instead of
              >just letting somebody typing it in just a string field?
              >
              In terms of the W3C schema language I suggested an _enumeration_ below:
              >
              >><xsd:simpleTy pe name="USState">
              >> <xsd:restrictio n base="xsd:strin g">
              >> <xsd:enumeratio n value="AK"/>
              >> <xsd:enumeratio n value="AL"/>
              >> <xsd:enumeratio n value="AR"/>
              >> <!-- and so on ... -->
              >> </xsd:restriction >
              >></xsd:simpleType>
              >
              Or are you now talking about a .NET enumeration defined with C# or VB.NET?
              >
              --
              >
              Martin Honnen --- MVP XML
              http://JavaScript.FAQTs.com/

              Comment

              • Martin Honnen

                #8
                Re: xml schema design

                Andy B wrote:
                You have the right thing. Does it do the same thing a c# enum would do?
                either restrict the strings that can be used, or make useful names for
                meaningless numbers (like a c# enum does)?
                The simple type I posted is a restriction of xsd:string allowing only
                the enumerated string values (e.g. "AK" or "AL") to be used.

                --

                Martin Honnen --- MVP XML

                Comment

                • Andy B

                  #9
                  Re: xml schema design

                  Makes sense to me. I added all of the state codes to the schema.


                  "Martin Honnen" <mahotrash@yaho o.dewrote in message
                  news:eTyHzrMkIH A.4664@TK2MSFTN GP03.phx.gbl...
                  Andy B wrote:
                  >You have the right thing. Does it do the same thing a c# enum would do?
                  >either restrict the strings that can be used, or make useful names for
                  >meaningless numbers (like a c# enum does)?
                  >
                  The simple type I posted is a restriction of xsd:string allowing only the
                  enumerated string values (e.g. "AK" or "AL") to be used.
                  >
                  --
                  >
                  Martin Honnen --- MVP XML
                  http://JavaScript.FAQTs.com/

                  Comment

                  Working...