[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Element content
- From: Ronald Bourret <firstname.lastname@example.org>
- To: Wayne Steele <email@example.com>
- Date: Wed, 14 Mar 2001 09:47:41 -0800
You might also consider making the middle name element optional. For
<!ELEMENT Person (FirstName, MiddleName?, LastName)>
Depending on your personal philosophy, a zero-length strengh might be
different from a missing element.
Wayne Steele wrote:
> A DTD cannot express this constraint.
> Anywhere CDATA can occur, an empty string is equally welcome.
> If you have a lot of constraints that you cannot express using DTDs, you
> might want to look at Schematron:
> >From: Mick McRae <Mick.McRae@abci.gov.au>
> >I have a basic XML document which references a DTD. The document may have
> >some tags as follows;
> ><?xml version="1.0" encoding="UTF-8"?>
> ><!DOCTYPE StaffReport SYSTEM "file:/opt/app/java/staff.dtd">
> > <Person>
> > <Firstname>Mick</Firstname>
> > <MiddleName></MiddleName>
> > <Surname></Surname>
> > <Person>
> >Is it possible within the DTD to specify that certain elements cannot be
> >empty? For example, in the sample XML above, I would like
> ><MiddleName></MiddleName> to be valid, as a middle name is not required,
> >but <Surname></Surname> not valid, as a surname is required. Can I do this
> >or do I need to explicity test for the tag name and length when pasring the
> >document using SAX?
> >Any help appreciated?