José Abílio Oliveira Matos <[EMAIL PROTECTED]> schrieb am 18.10.04 18:31:41: > > > > > +std::string cleanID(std::string orig) > > +{ > > + // Ok, I can't find it on the web right now, but if I recall > > + // correctly SGML allows only letters, '_', '$' and digits in IDs, > > + // starting with a letter or '_'. > > + // XML is a little more relaxed and allows ':', '.', '-' and other > > chars, > > + // although ':' is deprecated since namespaces were introduced. > > + // I made an adhoc scheme which only allows letters and digits, > > + // converts many of the special chars on my keyboard to '_' > > + // and deletes the rest. > > + // Note that OpenJADE thinks even '_' is illegal, which I doubt very > > much. > > + // Andreas Vox > > From: > http://www.docbook.org/tdg/en/html/ref-elements.html#common.attributes > > Attribute Types > > ID > An ID. IDs are names that must be globally unique within the document. > The ID attribute declares the ID. > > NAME > A name. A name must begin with a letter and can consist of letters, > digits, hyphens, and periods. > > This answers your question. :-) >
Jose and Andreas, it is not that simple! The underscore may very well be allowed in the value of an ID attribute, at least in SGML! This quite tricky subject is dealt in: character "_" not allowed in value of attribute ID http://www.karakas-online.de/forum/viewtopic.php?t=872 I suggest to leave validation to validating parsers, or, if you want to validate, then use an external one, don't try to reinvent the wheel. SGML can be quite tricky at this - and that was a reason that led to XML, namely that parsing SGML can be a challenge to program. -- Regards Chris Karakas http://www.karakas-online.de