4 ms·
Is there a legitimate use case for being able to recursively define entities like that?
by caseydurfee 14y ago
Is there a legitimate use case for being able to recursively define entities like that?
- lukeschlather 14y agoI don't see any recursion. Recursion would be an infinite loop and presumably a good parser would catch that.
- zurn 14y agoNo. Recursion can terminate and still be called recursion. (news.yc used to be a Lisp hangout)
- 3rd3 14y agoNot sure if you could abort an recursion in XML.
- Nitramp 14y agoIf you read the OP carefully, you'll see he's quite aware of the terminology. There really isn't any recursion in that XML snippet, none of the entities refers to itself, directly or transitively. If there was, the file would be invalid and the error probably caught by the parser before dying from memory exhaustion. There's no way to terminate recursion in XML entities.
- halter73 14y agoLook again. There's no actual recursion going on. It's fairly trivial to identify recursion in DTD entities.
- lmm 14y agoRather than nitpicking the terminology, can we answer the actual question: is there any legitimate use case for defining an entity in terms of another entity?
- byuu 14y agoRight, that's the root of the problem: feature creep. Common with design-by-committee. As with any feature, there are possible use cases. Perhaps you want to create a form document and use custom entities that you modify later to fill the document out. But the amount of times that's useful is not likely to be worth the potential harm of things like billion laughs. Easy to separate that functionality, and have your XML parser do an element data replace with your own custom tokens. Eg node.replace("{name}", customerName);
- Nitramp 14y agoDTD entities come from SGML, and are still commonly used as an extensibility/modularity mechanism in XML. XML power users (e.g. for documentation) commonly have DTDs that refer to entities that can be replaced to customize the format. IBM's DITA is an example for this. Having only one level of DTD expansion would make that much less powerful. I think that's a legitimate use case, but the resulting system is still a mess IMHO. Like many macro systems it's very hard to understand and debug, and on top of it you have to understand a relatively obscure format that isn't even XML (DTDs). That being said, like many of the things in XML, DTDs and entities not very useful outside of publishing/markup use cases, and dangerous on top of it (not only for the billion laughs, e.g. including system entities).
- andrewcooke 14y agoit's really the underlying macro system that's recursive - http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.3.2 http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.3.2 and that's probably because macros systems typically are recursive since they are otherwise fairly limited, so this is a way to give them sufficient expressive power. so the explanation is probably "tradition" (and likely made more sense in sgml, which was the precursor to html).
- deleted 14y ago[deleted]