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 ?



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