OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: Writing a DTD

[ Lists Home | Date Index | Thread Index ]
  • From: Rick JELLIFFE <ricko@geotempo.com>
  • To: xml-dev@lists.xml.org
  • Date: Sun, 05 Nov 2000 23:31:13 +0800

Rick JELLIFFE wrote:
> Pramod Rao Pesara wrote:
> >
> > thanks a lot. But is there a way to represent special characters like "(",
> > ")" and "/" in a DTD?
> > Pramod.
> It sounds like Pramod is expecting a DTD to act like a grammar over
> tokens or strings, like a perl regular expression.  Instead, a DTD
> element declaration's content model is a grammar over which elements can
> appear as a child.
> So there is no way in XML DTDs to say that any particular string or
> token must appear in data.  (If you want that, you will have to use an
> external function referenced using a notation declaration.)
> YOu can specify the allowed tokens in an attribute value, but these
> tokens are whitespace separated names, not punctuation marks.
> XML DTDs are not like YACC, to let you parse arbitrary data. Instead,
> XML predefines certain delimiters and treats the various tags it finds
> as signifying various "information items": elements, attributes, and so
> on.
> If you want to be able to parse arbitrary data into XML using DTDs, you
> should use an SGML parser to read the data in, then normalize the data
> out as XML.  SGML has many facilities for parsing strings and treating
> characters as start or end tags.
> Another approach that might be useful is to use XML Schemas.  In XML
> Schemas, you can assign datatypes to "simple" content (attribute values,
> element content which has no subelements).  You can declare that the
> element contains a "string", and then use a regular expression (like in
> perl) to describe the data. This gives you strong datatyping.  However,
> XML Schemas does not let you assign subpatterns to identifiers (like
> perl does) which you can then retrieve in some program, and if you
> decide your data does need to have subelements after all you must switch
> off datatyping by redeclaring the element as a "complex type".
> In other words, XML does not provide good facilities yet to parse data
> which has "embedded notations" and XML Schemas does not have good
> facilities for validating data that has "embedded notations which
> include markup".
> I hope this is helpful.
> Rick Jelliffe


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS