[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xml schema validation ?

  • From: Jeff Rafter <jeffrafter@e...>
  • To: Mandeep Bhatia <mbhatia@M...>
  • Date: Wed, 14 Mar 2001 14:42:58 -0800

mandeep bhatia
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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.