Xsd Xml Schema - Same Element With Different Properties

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • myghty
    New Member
    • Aug 2006
    • 2

    #1

    Xsd Xml Schema - Same Element With Different Properties

    Hi!

    I am writing an xml schema and i came to an problem. I want to have
    element "protocol" 2 times but each time with different properties. It also has
    an element access also each time different properties.
    I have tried the choice option but my validation tool says that a cant use the same element. Is it possible to solve this in an different way?

    Code:
            <xs:choice>
              <xs:element name="protocol">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="type" type="xs:string" />
                    <xs:element name="version" type="xs:string" />
                    <xs:element name="timeout" type="xs:integer" />
                    <xs:element name="access" minOccurs="1" maxOccurs="1">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="security_level" type="xs:string" />
                          <xs:element name="user_security_name" type="xs:string" />
                          <xs:element name="user_context_name" type="xs:string" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            <xs:element name="protocol">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="type" type="xs:string" />
                    <xs:element name="access" minOccurs="1" maxOccurs="1">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="community" type="xs:string" />
                          <xs:element name="set_community" type="xs:string" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
             </xs:element>
    Is it possible to solve this? Please help.
    Last edited by Dormilich; Jan 22 '09, 09:44 AM. Reason: added [code] tags
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Choose more descriptive names in stead of protocol call them

    protocol_apples

    and

    protocol_pears

    Where you replace apples and pears with something sensible of course :D

    Comment

    • myghty
      New Member
      • Aug 2006
      • 2

      #3
      Hi!

      The problem is that i can't use different names and that the shema should be
      with http://www.w3.org/2001/XMLSchema standard.

      Comment

      • Christy
        New Member
        • Aug 2006
        • 7

        #4
        Ok...
        u could try

        Code:
        <xs:element name="protocol">
        <xs:complexType>
        <xs:sequence>
        <xs:element name="type" type="xs:string" use="optional" />
        <xs:element name="version" type="xs:string" use="optional"/>
        ........
        so you could use those elements only when u need them

        tell me if that solves your problem
        Last edited by Dormilich; Jan 22 '09, 09:45 AM. Reason: added [code] tags

        Comment

        Working...