OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: xml schema validation ?


>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"
      xsi:schemaLocation="http://book http://book.com/book.xsd">

<?xml version="1.0"?>
<xsd:schema targetNamespace="http://book"
  <!-- 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:complexType name="book">
      <xsd:element name="author" type="nonEmptyString" nullable="false"/>
      <xsd:element name="price" type="xsd:positiveInteger"/>

Jeff Rafter
Defined Systems

----- Original Message -----
From: "Mandeep Bhatia" <mbhatia@MH2.Com>
To: "XML DEV" <xml-dev@lists.xml.org>
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
    there should be valid text in
<author> element.
       <price>23</price> ' price should always be greater than 0.

can somebody send me an xml document and its schema which meets
conditions like ones in above document.