XML Schema and empty elements

I'd like to have my schema specify that not only are certain elements required, but that they can't be blank. I can't seem to find how to specify this. I thought it was the nillable attribute, but that doesn't prevent blank elements.

On Thu, July 26, 2007 10:51, Timothy Reaves wrote:
I'd like to have my schema specify that not only are certain elements required, but that they can't be blank. I can't seem to find how to specify this. I thought it was the nillable attribute, but that doesn't prevent blank elements.
Got this one figured out. Nevermind. :-}

Hi Timothy, Thanks for the note, however, do you mind if you share with the rest of us your solution? The nillable flag if disabled by default. If set it specifies that an element can have no content but in that case the xsi:nil attribute needs to be set to true. I have not used it in a real application but I believe it is useful when you want to express data structures in XML and you need the option to be able to not specify any value for the fields, similar with setting a variable to null in a programming language like Java. If you want an element to have some content then how you specify that depends whether its content is * element only * specified by a simple type * mixed (elements and text) In the first case when an element contains only other elements than you need to make sure that not all the child elements are optional so you have some required content. In the second case it depends on the type set on an element. If the type does not accept the empty string as a valid value then you do not need to specify anything else. If the empty string is allowed than you can try specifying a constraining facet on that type, for instance in case of xs:string you can specify that the minimum length should be greater than zero. In the third case it is a little more difficult because XML Schema does not enforce constraints on the text part of an element that contains mixed content (both elements and text). The most you can do probably is to deal with that as in case of element only content and require some structure inside that element. Of course if you allow for instance Schematron embedded rules in your schema then this constraint can be easily expressed as a Schematron rule. Best Regards, George --------------------------------------------------------------------- George Cristian Bina <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com Timothy Reaves wrote:
On Thu, July 26, 2007 10:51, Timothy Reaves wrote:
I'd like to have my schema specify that not only are certain elements required, but that they can't be blank. I can't seem to find how to specify this. I thought it was the nillable attribute, but that doesn't prevent blank elements.
Got this one figured out. Nevermind. :-}
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user
participants (2)
-
George Cristian Bina
-
Timothy Reaves