Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xml-dev] Validation of missing elements in xml:

From: "Michael Kay" <mike@--------.--->
To: "'Sudheshna Iyer'" <sudheshnaiyer@-------.--->,<xml-dev@-----.---.--->
Date: 4/3/2006 3:24:00 PM
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: [xml-dev] 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>
> 
>


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent