[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Writing a DTD
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|