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

RE: Validation of missing elements in xml:


xml validation through xsd
With a DTD, there are very few ways to constrain the textual content of an
element (you can constrain it to be EMPTY, but not to be non-empty).

In XML Schema, you can declare the element to be of type my:non-empty-string
where my:non-empty-string is a simple type derived from xs:string using the
facet <minLength value="1"/>

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Sudheshna Iyer [mailto:sudheshnaiyer@h...] 
> Sent: 03 April 2006 15:59
> To: xml-dev@l...
> Subject:  Validation of missing elements in xml:
> 
> Team,
> 
> I have the simple following xml and dtd:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE Person SYSTEM "Person.dtd">
> <Person>
> 	<name>aaa</name>
> 	<email>aaa.bbb@x...</email>
> </Person>
> 
> DTD:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!ELEMENT Person (name, email)>
> <!ELEMENT email (#PCDATA)>
> <!ELEMENT name (#PCDATA)>
> 
> As per the DTD,  please note that "name"and "email" elements 
> are required 
> and if I validate the above with xmlspy
> xml is valid and wellformed.
> 
> But I want to catch the empty element scenario. for eg, if I 
> remove the 
> value of the "name" element from person.xml:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE Person SYSTEM "Person.dtd">
> <Person>
> 	<name></name> -----> see this.
> 	<email>aaa.bbb@x...</email>
> </Person>
> 
> and validate the xml through xmlspy, xml is still valid and 
> wellformed.
> 
> How do I catch these empty element problems through DTD? or 
> is it possible 
> through xsd? What is that I need to include
> in dtd or xsd to validate empty elements in dtd or xsd?
> 
> Thanks for your help.
> 
> _________________________________________________________________
> Express yourself instantly with MSN Messenger! Download today 
> - it's FREE! 
> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> 
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://www.oasis-open.org/mlmanage/index.php>
> 
> 



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.