0
我使用的xsd:schema將用於生成所需的xml,我在xsd:schema中有一個標題字段。如何驗證xsd:schema中的textfield元素
我想從xsd:schema驗證它,只有當用戶嘗試將超過,1個字符的值都會生成錯誤。
下面是我XSD的部分:模式
<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>
我的手段,我們可以驗證它<xsd:element name="Title" minOccurs="0" maxOccurs="1" type="xsd:normalizedString"/>
請建議!
感謝我們能期望的錯誤信息被voiliated時!像「你不能有超過10個字符的標題」 – 2010-09-09 05:16:57
我不認爲可以直接在你的XSD文件中定義它,如果這是你的意思。當驗證程序識別標題太長並顯示相應的錯誤消息時,您的代碼必須捕獲異常。你使用哪種編程語言? – uloBasEI 2010-09-09 18:47:50