Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,069
    Thanks
    4
    Thanked 8 Times in 8 Posts

    Schema -- add maxlength to complexType

    Given the following schema I want to set a maxlength for the ClientOrderId element I haven't been able to find anything on the web on how to do this when it is a complexType Does someone have an idea where i need to look to find this? I have scoured the W3C site on Schemas and have not been able to find it there.

    TIA


    Code:
    <?xml version="1.0"?>
    <xs:schema  xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    
    <xs:element name="user">
    	<xs:complexType>
    		<xs:sequence>
    			<xs:element ref="FirstName" maxOccurs="1" />
    			<xs:element ref="LastName" maxOccurs="1" />
    			<xs:element ref="Company" maxOccurs="1" />
    			<xs:element ref="Position" maxOccurs="1" />
    			<xs:element ref="MasterAccount" maxOccurs="1" />
    			<xs:element ref="SecondaryAccount" maxOccurs="1" />
    			<xs:element ref="Version" maxOccurs="1" />
    			<xs:element ref="Email" minOccurs="0" maxOccurs="1" />
    			<xs:element ref="Telephone" minOccurs="0" maxOccurs="1" />
    			<xs:element ref="ApplicantID" maxOccurs="1" />
    			<xs:element name="ClientOrderId" minOccurs="0" maxOccurs="1" />
    		</xs:sequence>
    	</xs:complexType>
    </xs:element>
    
    <xs:element name="FirstName" nillable="false">
    	<xs:simpleType>
    		<xs:restriction base="xs:string">
    			<xs:maxLength value="20" />
    		</xs:restriction>
    	</xs:simpleType>
    </xs:element> 
    
    <xs:element name="LastName" nillable="false">
    	<xs:simpleType>
    		<xs:restriction base="xs:string">
    			<xs:maxLength value="20" />
    		</xs:restriction>
    	</xs:simpleType>
    </xs:element>
    
    <xs:element name="Company" nillable="false">
    	<xs:simpleType>
    	    <xs:restriction base="xs:string">
    			<xs:maxLength value="40" />
    	    </xs:restriction>
    	</xs:simpleType>
    </xs:element> 
    
    <xs:element name="Position" nillable="false">
    	<xs:simpleType>
    	    <xs:restriction base="xs:string">
    			<xs:maxLength value="32" />
    	    </xs:restriction>
    	</xs:simpleType>
    </xs:element>
    
    <xs:element name="MasterAccount" nillable="false">
    	<xs:simpleType>
    	    <xs:restriction base="xs:string">
    			<xs:length value="6" />
    	    </xs:restriction>
    	</xs:simpleType>
    </xs:element> 
    
    <xs:element name="SecondaryAccount" nillable="false">
    	<xs:simpleType>
    	    <xs:restriction base="xs:string">
    			<xs:length value="6" />
    	    </xs:restriction>
    	</xs:simpleType>
    </xs:element>
    
    <xs:element name="Version" nillable="false">
    	<xs:simpleType>
    		<xs:restriction base="xs:string">
    			<xs:length value="6" />
    		</xs:restriction>
    	</xs:simpleType>
    </xs:element>
    
    <xs:element name="Email" nillable="true">
    	<xs:simpleType>
    	    <xs:restriction base="xs:string">
    			<xs:maxLength value="50" />
    	    </xs:restriction>
    	</xs:simpleType>
    </xs:element> 
    
    <xs:element name="Telephone" nillable="true">
    	<xs:simpleType>
    		<xs:restriction base="xs:string">
    			<xs:maxLength value="20" />
    		</xs:restriction>
    	</xs:simpleType>
    </xs:element>
    
    <xs:element name="ApplicantID" nillable="false">
    	<xs:simpleType>
    		<xs:restriction base="xs:string">
    			<xs:maxLength value="20" />
    		</xs:restriction>
    	</xs:simpleType>
    </xs:element>
    
    <xs:element name="ClientOrderId" nillable="true">
    	<xs:complexType>
    		<xs:attribute name="idOwner" type="xs:string" use="optional" />
    	</xs:complexType>	
    </xs:element>
    
    </xs:schema>

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Code:
    <xs:element name="ClientOrderId" nillable="true">
    	<xs:complexType>
    		<xs:attribute name="idOwner" type="xs:string" use="optional" />
    	</xs:complexType>	
    </xs:element>
    ClientOrderId is xs:complexType that means is made of other type of data in this case idOwner which is attribute. you can give a maxLength only to a simpleType like idOwner.

    Code:
    <xs:element name="ClientOrderId" nillable="true">
    	<xs:complexType>
    		<xs:attribute name="idOwner" use="optional">
                          <xs:simpleType>
                                <xs:restriction base="xs:string">
                                       <xs:maxLength value="12"/>
                                </xs:restriction>
                          </xs:simpleType>
                    </xs:attribute>
     	</xs:complexType>	
    </xs:element>
    best regards

  • #3
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,069
    Thanks
    4
    Thanked 8 Times in 8 Posts
    thanks for the reply


    so my choices then are to

    1) remove the idOwner attribute to then make the ClientOrderId a simpleType which I can then set a maxlength of the ClientOrderId to 40

    or
    2) add a node to the ClientOrderId element and make that node a simple type which i can then set a maxlength to . HMMM

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by miranda View Post
    thanks for the reply

    so my choices then are to

    1) remove the idOwner attribute to then make the ClientOrderId a simpleType which I can then set a maxlength of the ClientOrderId to 40

    or
    2) add a node to the ClientOrderId element and make that node a simple type which i can then set a maxlength to . HMMM
    1) look like that:
    Code:
    <ClientOrderId>max 40 chars length</ClientOrderId>
    2) look like that:
    Code:
    <ClientOrderId idOwner="...">
       <newnode>max 40 chars length</newnode>
    </ClientOrderId>
    3) the modified schema from my post look like that:
    Code:
    <ClientOrderId idOwner="max 40 chars length">
    ......empty or anything
    </ClientOrderId>
    what data must be max 40 chars length, ClientOrderId? or any other subnode of it. In that last case what's wrong with restricting idOwner length?
    Also on the last case we can't talk about a maxLength of a set of nodes( I can't imagine how).

    best regards


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •