...

View Full Version : Schema -- add maxlength to complexType



miranda
10-14-2008, 09:22 PM
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




<?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>

oesxyl
10-14-2008, 10:19 PM
<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.



<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

miranda
10-14-2008, 10:50 PM
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

oesxyl
10-14-2008, 11:15 PM
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:


<ClientOrderId>max 40 chars length</ClientOrderId>


2) look like that:


<ClientOrderId idOwner="...">
<newnode>max 40 chars length</newnode>
</ClientOrderId>


3) the modified schema from my post look like that:


<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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum