[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xml schema validation ?
Mandeep, >I am looking for a sample XML document and its schema which validates >that an element should not be null Based on your example it seems that you actually want non-empty content in addition to non-nullable content. Because of this I would recommend a solution which uses a string which does not allow empty content in addition to 'nullable="false"' (which disallows use of xsi:null in schema instances) >can somebody send me an xml document and its schema which meets >conditions like ones in above document. I have attached a valid schema and a *schema invalid* XML instance. Running this through a schema validator which supports Datatypes should raise an error. Finding a schema validator which supports datatype validation may be a different matter. As I understand it XSV does not currently. <?xml version="1.0"?> <book xmlns="http://book" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xsi:schemaLocation="http://book http://book.com/book.xsd"> <author></author> <price>23</price> </book> <?xml version="1.0"?> <xsd:schema targetNamespace="http://book" xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"> <!-- this simple type states that the content must be a string with at least one non Whitespace character --> <xsd:simpleType name="nonEmptyString"> <xsd:restriction base="xsd:string"> <xsd:minLength value="1"/> <xsd:whiteSpace value="collapse"/> </xsd:restriction> </xsd:simpleType> <xsd:complexType name="book"> <xsd:sequence> <xsd:element name="author" type="nonEmptyString" nullable="false"/> <xsd:element name="price" type="xsd:positiveInteger"/> </xsd:sequence> </xsd:complexType> </xsd:schema> Regards, Jeff Rafter Defined Systems ----- Original Message ----- From: "Mandeep Bhatia" <mbhatia@M...> To: "XML DEV" <xml-dev@l...> Sent: Wednesday, March 14, 2001 11:27 AM Subject: xml schema validation ? Hi List, I am new to list and XML. i.e <book> <author></author> ' now if author is not null this should not be allowed there should be valid text in <author> element. <price>23</price> ' price should always be greater than 0. </book> can somebody send me an xml document and its schema which meets conditions like ones in above document. Regards, Mandeep
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|