tags:

views:

23

answers:

1

hi Guys,

I am using xsd:schema which will be used to generated desired xml, I have a title field in xsd:schema.

I want to validate it from xsd:schema only that whenever user try to put values more than 10 characters, it will generate the error.

Below is the part of my xsd:schema

<xsd:sequence>
    <xsd:element name="Title" minOccurs="0" maxOccurs="1" type="xsd:normalizedString"/>         
    <xsd:element name="City" minOccurs="0" maxOccurs="1" type="tcmi:SimpleLink">
        <xsd:annotation>
            <xsd:appinfo>
                <tcm:linktype>ComponentLink</tcm:linktype>
                <tcm:AllowMultimediaLinks>false</tcm:AllowMultimediaLinks>
                <tcm:AllowedTargetSchemas>
                    <tcm:TargetSchema xlink:href="tcm:227-190428-8" xlink:title="City"/>
                </tcm:AllowedTargetSchemas>
            </xsd:appinfo>
        </xsd:annotation>
    </xsd:element>
    <xsd:element name="FlightLinkText" minOccurs="0" maxOccurs="1" type="xsd:normalizedString"/>                
</xsd:sequence>

I means that can we validate it from <xsd:element name="Title" minOccurs="0" maxOccurs="1" type="xsd:normalizedString"/>

Please suggest!

A: 

Have you tried something like:

<xsd:element name="Title" minOccurs="0" maxOccurs="1">
  <xsd:simpleType>
    <xsd:restriction base="xsd:normalizedString">
      <xsd:maxLength value="10"/>
    </xsd:restriction>
  </xsd:simpleType>
</xsd:element>
uloBasEI
Thanks can we desired error messages when is voiliated! something like "You can not have title more than 10 characters"
MKS
I don't think that is possible to define it directly in your XSD file, if it is what you mean. Your code will have to catch the exception when the validator identifies that the title is too long and display the appropriate error message. Which programming language are you using?
uloBasEI